Google Chrome中的getElementById问题 [英] getElementById problem in Google Chrome

查看:703
本文介绍了Google Chrome中的getElementById问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个简单的行

  alert(window.parent.frames [0] .document.getElementById('textToSearch' )。值); 

我有两个框架,第一个带有id为'textToSearch'的文本字段
我想要获取第二帧中文本字段的值
上面的行来自第二帧的html文件
我只在谷歌浏览器中出现此错误,在IE或FF工作正常。


未捕获的TypeError:无法调用未定义的方法'getElementById'

任何想法?



预先致谢

我认为是什么问题。我在系统本地文件上试用谷歌浏览器上面的代码。由于谷歌浏览器的安全设置,这个用例是不可能的。如果我移动Web服务器上的所有文件,这将作为一个魅力
感谢所有的支持,这个线程可以被关闭现在


I have this simple line

alert(window.parent.frames[0].document.getElementById('textToSearch').value);

I have 2 frames, first with a text field with id 'textToSearch' I want to get the value of the text field in the second frame The line above is on the html file from second frame I get this error only in Google Chrome, in IE or FF works fine.

Uncaught TypeError: Cannot call method 'getElementById' of undefined

Any ideas?

Thanks in advance

解决方案

Finally i figure what was the problem. I try the code from above on Google Chrome on a system local file. Due the security settings of Google Chrome this usecase is impossible. If i move all files on a web server this will work as a charm Thanks all for your support, this thread can be closed now

这篇关于Google Chrome中的getElementById问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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