I'm working with cordova 3.5
I've an iframe setup as following:
<iframe src="http://localhost/test/index.html" style="width:100%;height:90%" onLoad="checkforclose(this);"></iframe>
And the JS is the following:
<script type="text/javascript">
function checkforclose(pageURL) {
var urlFrame = pageURL.contentWindow.location; //WORKS
alert(urlFrame); //WORKS
alert(urlFrame.indexOf('test')); //DOESN'T WORK EVEN FOR ANY VALUE - RETURNS UNDEFINED
}
</script>
The snippet works, because the first two lines works. But the third don't. Even more, in JSFiddler works. I'm very lost with this.
Thanks in advance
Try alert(urlFrame.href.indexOf('test'));
The reason it doesn't work is you are calling indexOf on a window.location (urlFrame) Object. It is throwing an error because indexOf() is not a function property of window.location.
Try this...
var urlFrame = pageURL.src
You are getting undefined because value of "urlFrame" is empty.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.