RobB said:
For most applications, the Location object - presumably due to its
importance - can be both written to & read as if it were a string (just
like its .href property). You're comparing a relative url to a
fully-qualified one. Try:
if (parent.frames.main.location.href.search('mediaselect.html') > -1)
{....
Calling a String method so, you'll need that .href in this case.
thank you very much Rob & Ivo for yr responses.. ok, after following yr
suggestion this is what I now have...
<script language="JavaScript" type="text/javascript">
if (parent.frames.main.location.href.search('mediaselect.html') > -1) {
// if (parent.frames.main.location.href == 'mediaselect.html') {
alert(' ')
document.write(" ")
} else {
document.write('<div id="sel"><a href="mediaselect.html" target="main">')
document.write('<img src="images/ch_media.jpg" name="selm" width="138"
height="24" border="0"></a></div>')
}
</script>
alert pops ok now, but: wben I switch to a file in that main frame
other than file mentioned in conditional cond. is still not met (i.e.,
that img/link still does not appear..)
I also tried this:
<script language="JavaScript" type="text/javascript">
if (parent.frames.main.location.href.search('audio.html') > -1) {
document.write('<div id="sel"><a href="mediaselect.html" target="main">')
document.write('<img src="images/ch_media.jpg" name="selm" width="138"
height="24" border="0"></a></div>')
}
if (parent.frames.main.location.href.search('wmp.html') > -1)
document.write('<div id="sel"><a href="mediaselect.html" target="main">')
document.write('<img src="images/ch_media.jpg" name="selm" width="138"
height="24" border="0"></a></div>')
}
</script>
and got exact same result..
this:
if (parent.frames.main.location.href.search('audio.html') > -1) ||
(parent.frames.main.location.href.search('audio.html') > -1) {
gave me an error on those '||'...... don't know what that's about either..
I don't understand why this is such a problem... I also use this
(to make sure a certain file is loaded in a frame when I reload):
function loc() {
parent.frames.main.location = 'mediaselect.html'
}
and call function in onload event handler in body tag.. and this works
fine.. why is testing whether or not a certain file is loaded in a frame
such a problem? again, many thanks for yr help.. Frances