Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Frames using javascripts to open external sites cause problems in IE (not Netscape)

Reply
Thread Tools

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

 
 
sdvoranchik
Guest
Posts: n/a
 
      01-08-2004
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.
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-31-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do prevent sites to be loaded in other sites frames? Stefan Caliandro HTML 2 02-14-2005 06:05 PM
will all these messages cause a problem . I am a new subscriber and my computer is downloading 100,000 messages. Will this cause any kind of a problem with my ability to store other items?? Camille White Camille White Computer Support 9 11-08-2004 01:13 AM
host's external javascripts disrupt my onload scripts David Virgil Hobbs Javascript 3 07-26-2004 01:43 AM
free javascripts sites Mr. x Javascript 1 11-03-2003 01:31 PM
Accessing external Javascripts for information John B. Javascript 1 07-04-2003 05:04 PM



Advertisments