Note: I see a few answers on running JavaScript when an iframe's source changes. I'm trying to run a JavaScript function on page load to change the header.
Basically, the following $(document).ready function has an if statement that doesn't seem to be reading the source correctly from my iframe.
Specifically, this "if(document.getElementById("obj").src == '/apex/MyDocumentsMobile')" statement doesn't do what I think it should be doing, asserting that the frames source is indeed '/apex/MyDcoumentsMobile'
$(document).ready(function() {
if(document.getElementById("obj").src == '/apex/MyDocumentsMobile'){
alert('wow'); //this doesn't work. I know my iframe has this src ,though.
headerChanger('Documents');
}
$(".app-wrapper").delay(500).fadeIn(500); //this works, so my page fades in
});
//This function is called on other parts of the page and changes the header text just fine
function headerChanger(heady){
head = heady;
var element=document.getElementById("headText");
element.innerHTML=heady;
}
<iframe id="obj" src="/apex/MyDocumentsMobile" style="height:8000px;width:100%;position:relative;-webkit-overflow-scrolling: touch; " >
</iframe>