[thelist] JavaScript error.
.jeff
jeff at members.evolt.org
Thu Feb 21 19:02:00 CST 2002
john,
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: John Kipling Lewis
>
> I have a web page that uses two iframes. One frame
> contains a list of CD's that our editors have picked
> and the other shows a list of possible catagories (Pop,
> Classical, Western).
>
> The second iframe uses a function on the main (top)
> page. I'm calling the fuctioned through
> top.funtion_name(). That is working fine.
>
> We have two virtual servers. One is www.domain_name.com
> and the other is domain_name.com. This isn't uncommon,
> most sites do it.
>
> For some reason, when someone visits the
> www.domain_name.com and clicks in the second iframe it
> tries to access the main (top) page through
> domain_name.com instead, and this creates an error:
>
> Error Line 30
> Permission Denied.
>
> This line is the one where the function is being called
> from.
>
> When you mouse over the link, it clearly states that it's
> going to go to domain_name.com, and since this isn't the
> parent window, it gives an error.
>
> Does anyone know why this might happen?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
it's because you've hardcoded your links to use absolute references. change
all instances of "http://allclassical.com/" or
"http://www.allclassical.com/" in <a>, <img>, <script>, <iframe>, <link>,
<object>, <embed> tags and any other tag that references external media to
"/".
the most problematic is your pick() function (which you're calling all
wrong, to begin with):
function pick() {
x='<iframe width=392 height=406
src="http://allmusic.com/com/b2k1/'+person+'-'+cat+'.html" align=left
frameborder="0" id="frametent"></iframe>';
document.getElementById("tent").innerHTML=x;
x='<iframe src="http://allmusic.com/com/b2k1/'+person+'.html"
frameborder="0" id="topnav" scrolling="no" height="30"
width="260"></iframe>';
document.getElementById("tnav").innerHTML=x;
if (cat=="s") {dex="Pop Singles"}
if (cat=="p") {dex="Pop Albums"}
if (cat=="r") {dex="Pop Reissues"}
if (cat=="m") {dex="Movie"}
if (cat=="d") {dex="DVD"}
if (cat=="c") {dex="Classical Album"}
if (cat=="g") {dex="Game"}
x=name+' > '+dex;
document.getElementById("title").innerHTML=x;
}
why write the html out for the <iframe> tag? why not just change the
location of the document in the <iframe>? sure would be a whole lot easier
and have greater support.
the lines with the <iframe> tags need to have the "http://allmusic.com/"
changed to "/". that should fix your error problems. however, you've got
*much* bigger problems in your complex reliance on javascript and therefore
needlessly locking out non-js users.
give this a read and then re-evaluate your strategy, please (begging):
Links and JavaScript Living Together in Harmony
http://evolt.org/article/thelist/17/20938/
good luck,
.jeff
http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/
More information about the thelist
mailing list