检查框架中加载的文件.. [英] checking for what file loaded in a frame..

查看:48
本文介绍了检查框架中加载的文件..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


我有一个非常简单的框架集,框架名称我在哪里检查是

''main''...为什么这不起作用?我的意思是这是正确的语法,

对吧?我也提出了一个测试警报,但是如果文件

我正在测试的是在''main''框架中加载,则警报不会出现..谢谢.. Frances


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


推荐答案

" Frances Del Rio"写了
"Frances Del Rio" wrote
if(parent.frames.main.location ==''mediaselect.html''){

我有一个非常简单的框架集,框架名称我在哪里检查是'
''主要'...为什么这不起作用?我的意思是这是正确的语法,对吧?我也提出了一个测试警报,但如果我正在测试的文件被加载到''main''框架中,则不会出现警报..谢谢.. Frances
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




你不想要位置对象,但是它的href属性。

尝试

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



alert(parent.frames.main.location.href);

first也许。

并注意各种令人讨厌的跨域安全限制错误如果主框架恰好包含来自另一个域的文档,则会发生


-

Ivo



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


Ivo写道:
" Frances Del Rio"写了
"Frances Del Rio" wrote
if(parent.frames.main.location ==''mediaselect.html''){

我有一个非常简单的框架集,框架名称我在哪里检查是'
''主要'...为什么这不起作用?我的意思是这是正确的语法,对吧?我也提出了一个测试警报,但如果我正在测试的
文件被加载到''main''框架中,则不会出现警报..谢谢.. Frances
你不要想要位置对象,但需要它的href属性。
尝试
if(parent.frames.main.location.href ==''mediaselect.html''){

警告(parent.frames.main.location.href);
首先也许。
并注意各种令人讨厌的跨域安全限制
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



错误发生如果主框架恰好包含来自另一个
域的文档。 -
Ivo


errors happen if the main frame happens to contain a document from another domain. --
Ivo




对于大多数应用程序来说,Location对象 - 可能是因为它的重要性b / b $ bb都可写入&安培;读起来好像是一个字符串(只是

喜欢它的.href属性)。你正在比较一个相对的网址和一个完全合格的网址。试试:


if(parent.frames.main.location.href.search(''mediasel ect.html'')> -1)

{....


调用String方法,在这种情况下你需要.href。



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.




RobB写道:


RobB wrote:
Ivo写道:
Ivo wrote:
" Frances Del Rio"写了
"Frances Del Rio" wrote
if(parent.frames.main.location ==''mediaselect.html''){

我有一个非常简单的框架集,名称为我正在检查的框架是主要的......为什么这不起作用?我的意思是这是正确的语法,对吧?我也提出了一个测试警报,但如果
我正在测试的文件被加载到''main''框架中,则不会出现警告..谢谢.. Frances
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



你不想要位置对象,但是它的href属性。
尝试
if(parent.frames.main.location.href ==''mediaselect.html' '){

警告(parent.frames.main.location.href);
首先也许。
并注意各种令人讨厌的跨域安全限制



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



域的文档。 br />



domain.

-
Ivo
--
Ivo



对于大多数应用程序,Location对象 - 可能是由于其重要性 - 可以是都写到&读起来好像是一个字符串(只是像它的.href属性一样)。你正在比较一个相对的网址和一个完全合格的网址。尝试:

if(parent.frames.main.location.href.search(''mediasel ect.html'')> -1)
{....

调用一个String方法,在这种情况下你需要.href。


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.




非常感谢Rob& Ivo对你的回复..好吧,在你关注之后我会建议这就是我现在所拥有的......


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


警告现在可以弹出,但是:wben我切换到该主框架中的文件
$ b除了条件cond中提到的文件之外的$ b。仍然没有满足(即,

img / link仍然没有出现..)


我也试过这个:

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


并得到完全相同的结果这个:

if(parent.frames.main.location.href.search(''audio.ht ml'')> -1)||

(parent.frames.main.location.href.search(''audio.ht ml'')> -1){


给了我一个''||''的错误......不知道那是什么......


我不喜欢不明白为什么这是一个问题......我也用这个

(以确保我重装时某个文件加载到一个框架中):


function loc(){

parent.frames.main.location =''mediaselect.html''

}


并在body标签中的onload事件处理程序中调用函数..这个工作

罚款..为什么要测试某个文件是否加载到框架中

这样的问题?再次,非常感谢你的帮助.. Frances




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



这篇关于检查框架中加载的文件..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆