473,390 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

checking for what file loaded in a frame..

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


Jul 23 '05 #1
14 2168
Ivo
"Frances Del Rio" wrote
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.
--
Ivo
Jul 23 '05 #2
Ivo wrote:
"Frances Del Rio" wrote
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. --
Ivo


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('mediasel ect.html') > -1)
{....

Calling a String method so, you'll need that .href in this case.

Jul 23 '05 #3


RobB wrote:
Ivo wrote:
"Frances Del Rio" wrote
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.
--
Ivo

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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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


Jul 23 '05 #4


Frances Del Rio wrote:


RobB wrote:
Ivo wrote:
"Frances Del Rio" wrote

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


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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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.ht ml') > -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

Jul 23 '05 #5
Frances Del Rio wrote:
Frances Del Rio wrote:


RobB wrote:
Ivo wrote:

"Frances Del Rio" wrote

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

--
Ivo

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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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.ht ml') > -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.

Jul 23 '05 #6
Frances Del Rio wrote:
Frances Del Rio wrote:


RobB wrote:
Ivo wrote:

"Frances Del Rio" wrote

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

--
Ivo

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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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.ht ml') > -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.

Jul 23 '05 #7
Frances Del Rio wrote:
Frances Del Rio wrote:


RobB wrote:
Ivo wrote:

"Frances Del Rio" wrote

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

--
Ivo

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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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.ht ml') > -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.

Jul 23 '05 #8
Frances Del Rio wrote:
Frances Del Rio wrote:


RobB wrote:
Ivo wrote:

"Frances Del Rio" wrote

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

--
Ivo

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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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.ht ml') > -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.

Jul 23 '05 #9
Frances Del Rio wrote:
Frances Del Rio wrote:


RobB wrote:
Ivo wrote:

"Frances Del Rio" wrote

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

--
Ivo

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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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.ht ml') > -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.

Jul 23 '05 #10


Frances Del Rio wrote:
Frances Del Rio wrote:


RobB wrote:
Ivo wrote:

"Frances Del Rio" wrote

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

--
Ivo

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('mediasel ect.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('mediasel ect.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.ht ml') > -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.ht ml') > -1) ||
(parent.frames.main.location.href.search('audio.ht ml') > -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.ht ml') > -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.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #11


....death to googlegroups !

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #12
JRS: In article <11********************@c13g2000cwb.googlegroups.c om>,
dated Tue, 14 Dec 2004 15:16:24, seen in news:comp.lang.javascript, RobB
<fe******@hotmail.com> posted :
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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk 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.
Jul 23 '05 #13
Dr John Stockton wrote:
JRS: In article <11********************@c13g2000cwb.googlegroups.c om>, dated Tue, 14 Dec 2004 15:16:24, seen in news:comp.lang.javascript, RobB <fe******@hotmail.com> posted :
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 ..innerHTMLproperty (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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk 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

Jul 23 '05 #14
JRS: In article <11**********************@z14g2000cwz.googlegroups .com>
, dated Thu, 16 Dec 2004 12:12:00, seen in news:comp.lang.javascript,
RobB <fe******@hotmail.com> posted :
Lines: 38 Dr John Stockton wrote:
JRS: In article

<11********************@c13g2000cwb.googlegroups. com>,
dated Tue, 14 Dec 2004 15:16:24, seen in news:comp.lang.javascript,

RobB
<fe******@hotmail.com> posted :
>Lines: 169
Please do not quote excessively; it wastes time and resources which

are
not yours. FAQ 2.3 para 6 refers.
...

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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk 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.
Jul 23 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: foldface | last post by:
Hi Given a web page using frames, is there anyway the left frame can request a page in the right frame and, most importantly, detect when it has fully loaded? Ideally this requires no changes to...
4
by: Mark | last post by:
I am loading source files into several iframes, with each load happening after some user-generated event (like clicking a button). The loading works but I need to determine when the source file is...
2
by: JPL Verhey | last post by:
(i hope somebody (else) will read and have an idea! Thnx) Hi, With a script in a popup window, I want to check if certain content is present in a page loaded into the frame "main" of the...
4
by: Andrew Poulos | last post by:
How can a page know which frame in a frameset it is in? Andrew Poulos
3
by: Jim Cobban | last post by:
I have a set of web pages that are organized in pairs. One of each pair contains a graphic and the other is an extended description of the graphic. I am trying to set it up that selecting a single...
3
by: bfmcfarlane | last post by:
I have an appication that allows users to upload and download files. This application is only accessed when a user clicks on an "Upload / Download" link from within our main application. A new...
6
by: Sunfire | last post by:
Is there a way you can test what page is loaded from inside a master page? What I need to do is test to see what page is loaded inside the master page and then gray out the root item linked to that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.