jquery - Check IFRAME URL and reload if found - Javascript -
i'm trying page name of iframe page (that on same server) , if it's not following name(s): 'index1.php'
or 'indextom.php'
don't if page name reload iframe. here have set doesn't work reason resultnfo true , iframe never reloads?
//check url of iframe var currenturl = document.getelementbyid("frmcontent").contentwindow.location.href; var word = 'index1.php'; var regex = new regexp( '\\b' + word + '\\b' ); var resultnfo = regex.test( currenturl ); if (resultnfo = true){ document.getelementbyid("frmcontent").contentdocument.location.reload(true); } var word = 'indextom.php'; var regex = new regexp( '\\b' + word + '\\b' ); var resultnfo = regex.test( currenturl ); if (resultnfo = true){ document.getelementbyid("frmcontent").contentdocument.location.reload(true); } alert('url is: '+currenturl+'\n'+resultnfo);
why don't resultnfo = currenturl.indexof('indextom.php') !== -1
?
you have lot of problems here, should use for
loop really
not tested demo
var urls = ['indextom.php', 'index1.php'], frame = document.getelementbyid('frmcontent').contentdocument; for( var = 0; < urls.length; i++ ) { var url = urls[i]; if( frame.location.href.indexof(url) !== -1 ) { frame.location.reload() } }
try along lines of above code, it's lot cleaner.
Comments
Post a Comment