Reputation: 11578
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
Upvotes: 0
Views: 90
Reputation: 540
Try this...
var urlFrame = pageURL.src
You are getting undefined because value of "urlFrame" is empty.
Upvotes: 0
Reputation: 121
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.
Upvotes: 2