SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript error in IE, Firefox fine

    Hi, I have some code to open a new window with a video in it, i'm having a problem in IE (code below), the error it is giving me is 'Invalid argument', it works fine in Firefox.

    Code:
    <area shape="poly" coords="628,152,281,162,280,240,625,240,784,240,784,4,628,4" href="javascript: void window.open ('http://www.example.com/video/index.php' , 'Video' , 'toolbar=0 , scrollbars=0 , location=0 , statusbar=0 , menubar=0 , resizable=0 , width=320 , height=270 , left=400 , top=300');" alt="Video" />
    Any ideas why IE doesn't like this, on the actual page there is some Macromedia produced JavaScript for Flash Video.

    Thanks,

    Stuart

  2. #2
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting open and close parentheses after void

    javascript: void(); window.open...

  3. #3
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that didn't seem to work either but when I took out the void it was fine although it gave a blank parent page after the pop-up arrived. I ended up putting javascript: void(); then the command in an onclick.

    Code:
    <area shape="poly" coords="628,152,281,162,280,240,625,240,784,240,784,4,628,4" href="javascript:void();" onclick="window.open('http://www.example.com/video/index.php', 'video', 'height=270,width=320', false);" alt="Video" />
    Cheers again.

  4. #4
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alternatively, you could have followed the onclick event with return false. For example:

    href="#" onclick="window.open(etc.~);return false;"

    Without the return false, the link is executed. The hash in the above href is a benign hack that prevents action from taking place if return false is forgotten. The return false simply prevents the link from executing after the script is executed. The above syntax is usually the preferred, for its safety and redundancy. Optionally, a real URL can be referenced by the href, to be executed if JavaScript is not enabled, but is ignored if JS is enabled.

  5. #5
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks JVLB, excellent tip, i'm a novice at this stuff so that will come in handy.


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
  •