checking for what file loaded in a frame..

F

Frances Del Rio

if (parent.frames.main.location == 'mediaselect.html') {

I have a very simple frameset, name of frame where I'm checking is
'main'... why is this not working? I mean this is correct syntax,
right?? I also put a test alert, but alert does not come up if file
I'm testing for is loaded in 'main' frame.. thank you.. Frances
 
I

Ivo

if (parent.frames.main.location == 'mediaselect.html') {

I have a very simple frameset, name of frame where I'm checking is
'main'... why is this not working? I mean this is correct syntax,
right?? I also put a test alert, but alert does not come up if file
I'm testing for is loaded in 'main' frame.. thank you.. Frances

You don't want the location object, but its href property.
Try
if (parent.frames.main.location.href == 'mediaselect.html') {
or
alert( parent.frames.main.location.href );
first perhaps.
And beware that all sorts of nasty cross-domain security restriction errors
happen if the main frame happens to contain a document from another domain.
 
R

RobB

Ivo said:
You don't want the location object, but its href property.
Try
if (parent.frames.main.location.href == 'mediaselect.html') {
or
alert( parent.frames.main.location.href );
first perhaps.
And beware that all sorts of nasty cross-domain security restriction errors
happen if the main frame happens to contain a document from another domain.

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.
 
F

Frances Del Rio

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
 
F

Frances Del Rio

Frances said:
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

ooopss.. had forgotten a '{'.. but even after correcting this it's still
not working.. now I put everything in a function..

function check() {
if (parent.frames.main.location.href.search('audio.html') > -1) {
alert('')
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) {
alert('')
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>')
}
}

and call function in body of file.. (also tried calling function in
body tag.. (onload... etc...)

<script language="JavaScript" type="text/javascript">
check();
</script>

I do get alert now, but if wmp.html or audio.html are loaded img/link I
want does not appear... I want it to appear if either of these two
files are loaded in 'main' frame; is 'mediaselect.html' is loaded I
don't want it to appear..) again, thank you for your help.. Frances
 
R

RobB

Frances said:
ooopss.. had forgotten a '{'.. but even after correcting this it's still
not working.. now I put everything in a function..

function check() {
if (parent.frames.main.location.href.search('audio.html') > -1) {
alert('')
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) {
alert('')
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>')
}
}

and call function in body of file.. (also tried calling function in
body tag.. (onload... etc...)

<script language="JavaScript" type="text/javascript">
check();
</script>

I do get alert now, but if wmp.html or audio.html are loaded img/link I
want does not appear... I want it to appear if either of these two
files are loaded in 'main' frame; is 'mediaselect.html' is loaded I
don't want it to appear..) again, thank you for your help.. Frances

Can't call document.write() on a loaded document as it discards the
current one, although it may appear to be successful in some browsers.
Try including that div in the original page and setting its .innerHTML
property (document.getElementById('sel').innerHTML) to the link/img
HTML string you need.
 
R

RobB

Frances said:
ooopss.. had forgotten a '{'.. but even after correcting this it's still
not working.. now I put everything in a function..

function check() {
if (parent.frames.main.location.href.search('audio.html') > -1) {
alert('')
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) {
alert('')
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>')
}
}

and call function in body of file.. (also tried calling function in
body tag.. (onload... etc...)

<script language="JavaScript" type="text/javascript">
check();
</script>

I do get alert now, but if wmp.html or audio.html are loaded img/link I
want does not appear... I want it to appear if either of these two
files are loaded in 'main' frame; is 'mediaselect.html' is loaded I
don't want it to appear..) again, thank you for your help.. Frances

Can't call document.write() on a loaded document as it discards the
current one, although it may appear to be successful in some browsers.
Try including that div in the original page and setting its .innerHTML
property (document.getElementById('sel').innerHTML) to the link/img
HTML string you need.
 
R

RobB

Frances said:
ooopss.. had forgotten a '{'.. but even after correcting this it's still
not working.. now I put everything in a function..

function check() {
if (parent.frames.main.location.href.search('audio.html') > -1) {
alert('')
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) {
alert('')
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>')
}
}

and call function in body of file.. (also tried calling function in
body tag.. (onload... etc...)

<script language="JavaScript" type="text/javascript">
check();
</script>

I do get alert now, but if wmp.html or audio.html are loaded img/link I
want does not appear... I want it to appear if either of these two
files are loaded in 'main' frame; is 'mediaselect.html' is loaded I
don't want it to appear..) again, thank you for your help.. Frances

Can't call document.write() on a loaded document as it discards the
current one, although it may appear to be successful in some browsers.
Try including that div in the original page and setting its .innerHTML
property (document.getElementById('sel').innerHTML) to the link/img
HTML string you need.
 
R

RobB

Frances said:
ooopss.. had forgotten a '{'.. but even after correcting this it's still
not working.. now I put everything in a function..

function check() {
if (parent.frames.main.location.href.search('audio.html') > -1) {
alert('')
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) {
alert('')
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>')
}
}

and call function in body of file.. (also tried calling function in
body tag.. (onload... etc...)

<script language="JavaScript" type="text/javascript">
check();
</script>

I do get alert now, but if wmp.html or audio.html are loaded img/link I
want does not appear... I want it to appear if either of these two
files are loaded in 'main' frame; is 'mediaselect.html' is loaded I
don't want it to appear..) again, thank you for your help.. Frances

Can't call document.write() on a loaded document as it discards the
current one, although it may appear to be successful in some browsers.
Try including that div in the original page and setting its .innerHTML
property (document.getElementById('sel').innerHTML) to the link/img
HTML string you need.
 
R

RobB

Frances said:
ooopss.. had forgotten a '{'.. but even after correcting this it's still
not working.. now I put everything in a function..

function check() {
if (parent.frames.main.location.href.search('audio.html') > -1) {
alert('')
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) {
alert('')
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>')
}
}

and call function in body of file.. (also tried calling function in
body tag.. (onload... etc...)

<script language="JavaScript" type="text/javascript">
check();
</script>

I do get alert now, but if wmp.html or audio.html are loaded img/link I
want does not appear... I want it to appear if either of these two
files are loaded in 'main' frame; is 'mediaselect.html' is loaded I
don't want it to appear..) again, thank you for your help.. Frances

Can't call document.write() on a loaded document as it discards the
current one, although it may appear to be successful in some browsers.
Try including that div in the original page and setting its .innerHTML
property (document.getElementById('sel').innerHTML) to the link/img
HTML string you need.
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Tue, 14 Dec 2004 15:16:24, seen in RobB
Lines: 169
Can't call document.write() on a loaded document as it discards the
current one, although it may appear to be successful in some browsers.
Try including that div in the original page and setting its .innerHTML
property (document.getElementById('sel').innerHTML) to the link/img
HTML string you need.

Please do not quote excessively; it wastes time and resources which are
not yours. FAQ 2.3 para 6 refers.
 
R

RobB

Dr said:
JRS: In article
dated Tue, 14 Dec 2004 15:16:24, seen in RobB



Please do not quote excessively; it wastes time and resources which are
not yours. FAQ 2.3 para 6 refers.

--
© John Stockton, Surrey, UK. [email protected] Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't
Mail News.

Dr. John:

Hoped my other (OT) comment would be self-explanatory. Please contact
googlegroups w/all complaints. Have no idea what is amiss...

Rob
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Thu, 16 Dec 2004 12:12:00, seen in
RobB said:
Lines: 38
News.

Dr. John:

Hoped my other (OT) comment would be self-explanatory. Please contact
googlegroups w/all complaints. Have no idea what is amiss...

Please do not quote excessively; it wastes time and resources which
are not yours. FAQ 2.3 para 6 refers. Read it. Don't blame the
service you chose to use; if necessary, blame your choice of service.


By the way, we already have a RobX, for some X in [A, C..Z]; like is
easier for others if authors use real (or simulated real) names of
sufficient length.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top