SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.open not work in Mozilla?

    I am trying to use the following javascript function to open a new window. It works fine for IE browsers, but not Mozilla.

    Code:
    settings = 'height='+screen.height+',width='+screen.width+',top=0,left=0,scrollbars=yes,directories=no,location=yes,menubar=yes,resizable=yes,status=yes,toolbar=yes';
    win = window.open(address, "newwindow", settings);
    Am I doing something wrong or does Mozilla not support the window.open function? Or is it something in the settings thats breaking it?

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you have it blocking all popups, including requested ones?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not that I know of. I simply installed it from the Mozilla site. I haven't messed with it's settings or anything.

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, nothing looks wrong, offhand. Does Mozilla give any errors?

    Do you have this page online where we could look at it?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure, online its http://parrish.krayzieland.com/new/links.php

    The external js is:
    Code:
    function newImage(arg) {
     if (document.images) {
      rslt = new Image();
      rslt.src = arg;
      return rslt;
     }
    }
    function changeImages() {
     if (document.images) {
      for (var i=0; i<changeImages.arguments.length; i+=2) {
       document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
      }
     }
    }
    function makevisible(cur,which)
    {
     strength=(which==0)? 1 : 0.4
     if (cur.style.MozOpacity)
      cur.style.MozOpacity=strength
     else if (cur.filters)
      cur.filters.alpha.opacity=strength*100
    }
    function NewWindow(mypage,myname,w,h)
    {
     LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
     TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
     settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no';
     win = window.open(mypage,myname,settings);
    }
    function viewLink(buttonobj)
    {
     var listToGet = buttonobj.name;
     var address = document.getElementById(listToGet + "select").options[document.getElementById(listToGet + "select").options.selectedIndex].value;
     
     var settings = 'height='+screen.height+',width='+screen.width+',top=0,left=0,scrollbars=yes,directories=no,location=yes,menubar=yes,resizable=yes,status=yes,toolbar=yes';
     var win = window.open(address, "newwindow", settings);
    }

  6. #6
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, Mozilla DOES give an error
    Quote Originally Posted by Javascript Console
    Error: document.getElementById(listToGet + "select") has no properties
    Source File: http://parrish.krayzieland.com/new/js/common.js
    Line: 38
    name and id property values shouldn't start with a number - only an alpha character or an underscore is valid. Change your ids from 1select and 2select to select1 and select2.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  7. #7
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, updated the files. It's still not working on Mozilla.

    How are you seeing that error? I don't get any errors from Mozilla.

  8. #8
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To see Mozilla errors

    Tools >> Web Development >> JavaScript Console

    Since you are using document.getElementById(), then logic would imply that the element you want to get must have an id.
    Code:
    <select name="select1" id="select1" size="5">
    Otherwise, you must obtain the reference in another way, like this
    Code:
    var selElem = button.form.elements["select" + button.name];
    var address = selElem.options[selElem.selectedIndex].value
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  9. #9
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Strange. Why does IE work on this and not Mozilla then? Is this one of IE's "it works because IE interprets the commands incorrectly?"

    Adding the id tag to the select window (stupid mistake, my apologies for bothering you with such an erroneous mistake) did the trick. Thank you!

  10. #10
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE is much more forgiving with syntax strictness. This is a vestige of the old browser wars, when they competed to be the easier development platform. IE cut lots of corners by allowing sloppy HTML (tag-soup), auto-exposing id'ed elements as window properties, etc.

    It was never supposed to be this way.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •