Frames using javascripts to open external sites cause problems in IE (not Netscape)

Discussion in 'Javascript' started by sdvoranchik, Jan 8, 2004.

  1. sdvoranchik

    sdvoranchik Guest

    We have an application that contains links that run javascripts to
    create pages in a separate frame. When these links open an external
    site, it causes the javascripts to no longer function. When we
    modified the links that invoke the javascripts from:
    <a href=javascript: top.doSomething> text </a>
    To:
    <span onclick=javascript:top.doSomething> text </span>
    The javascripts worked properly. Any ideas on why this now works or
    other solutions? This site works fine when viewed using Netscape
    4.76.
    sdvoranchik, Jan 8, 2004
    #1
    1. Advertising

  2. Re: Frames using javascripts to open external sites cause problemsin IE (not Netscape)

    sdvoranchik wrote:

    > We have an application that contains links that run javascripts to
    > create pages in a separate frame. When these links open an external
    > site, it causes the javascripts to no longer function.


    "Does not work" is a useless error description. [psf 4.11]

    You have had a look into the JavaScript Console and/or enabled
    the display of script errors before posting, have you not?

    > When we modified the links that invoke the javascripts from:
    > <a href=javascript: top.doSomething> text </a>


    You have been misusing the "javascript:" URI scheme. It is designed
    to generate (HTML) content from evaluated values, not to run code that
    does not do so. It is likely that, if top.doSomething is a method,
    a temporary document will be created with the return value of
    top.doSomething(...) as its content or with the definition string of
    top.doSomething(...) if you leave the call operator's parantheses out.
    If it is a non-function property, that document should contain its value.

    Since a URI is expected, you are not allowed to use unescaped spaces and
    special characters within it, so if you did, it explains why it did not
    work.

    > To:
    > <span onclick=javascript:top.doSomething> text </span>


    Since "javascript:" is a URI scheme, it does not belong into intrinsic
    event handlers' attribute values. Only Internet Explorer considers
    "javascript:" to be a semantical label defining the scripting language
    for that handler, other UAs will either consider it a label with no
    meaning and ignore it because there is no jump statement to refer to it,
    or show a script error if that language construct is unsupported for
    some reason. And (X)HTML attribute values need to be delimited by
    single or double quotes, if they are not only composed of a small subset
    of characters, so write

    <span onclick="top.doSomething">text</span>

    instead (use ' within the script code if you need string delimiters) and
    declare the default scripting language for event handlers within the
    HEAD element:

    <meta http-equiv="Content-Script-Type" content="text/javascript">

    What about users without support for client-side scripting?


    PointedEars
    Thomas 'PointedEars' Lahn, Jan 31, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Caliandro
    Replies:
    2
    Views:
    613
    Beauregard T. Shagnasty
    Feb 14, 2005
  2. Sara Khalatbari
    Replies:
    6
    Views:
    342
    Jeff Shannon
    Mar 16, 2005
  3. John B.
    Replies:
    1
    Views:
    99
    Evertjan.
    Jul 4, 2003
  4. Mr. x

    free javascripts sites

    Mr. x, Nov 1, 2003, in forum: Javascript
    Replies:
    1
    Views:
    90
    kaeli
    Nov 3, 2003
  5. David Virgil Hobbs

    host's external javascripts disrupt my onload scripts

    David Virgil Hobbs, Jul 22, 2004, in forum: Javascript
    Replies:
    3
    Views:
    144
    Thomas 'PointedEars' Lahn
    Jul 26, 2004
Loading...

Share This Page