kalster Posted November 27, 2012 Share Posted November 27, 2012 The code below does not pass the HTML 4.01 Transitional w3c validator. the part that fails validation is the word onload. I have tried moving that onload code to the body of the html. it validates fine but it does not work as it should. the page that loads the iframe has an anchor called tag. when a link is clicked in the iframe, the page that loaded the iframe should scroll up to the html anchor of tag but the code when in the body of the html only fires up once at the initial page load. Another problem is that i can't so easily change doc type to frames because i would then need to change many files that php included the html header. how can i get this code to work with the validator. thank you in advance. <a id="tag"></a> <iframe src="index.php" onload="this.contentwindow.document.onclick=location.href='#tag'" id="frame" width = "100%" scrolling="no" ></iframe> Link to comment https://forums.phpfreaks.com/topic/271231-iframe-onload-does-not-pass-validation/ Share on other sites More sharing options...
MDCode Posted November 27, 2012 Share Posted November 27, 2012 Moderator please delete my post ^.^ Link to comment https://forums.phpfreaks.com/topic/271231-iframe-onload-does-not-pass-validation/#findComment-1395513 Share on other sites More sharing options...
kalster Posted November 28, 2012 Author Share Posted November 28, 2012 this topic is solved the code below will validate and scroll up to the anchor of the page that loaded the iframe when the link in the iframe is clicked. the code will also resize the iframes height so that all the content is displayed. I found the resize code on the net and added the anchor code to it. if you are looking for the same code as i was then just put this code in the header and remove the onload or onclick code from within the iframe tag. <script type='text/javascript'> $(function(){ var iFrames = $("#iframe"); function iResize() { for (var i = 0, j = iFrames.length; i < j; i++) { iFrames[i].style.height = iFrames[i].contentwindow.document.body.offsetHeight + 'px'; location.href='#tag'; } } if ($.browser.safari || $.browser.opera) { iFrames.load(function(){ setTimeout(iResize, 0); }); for (var i = 0, j = iFrames.length; i < j; i++) { var iSource = iFrames[i].src; iFrames[i].src = ''; iFrames[i].src = iSource; } } else { iFrames.load(function() { this.style.height = this.contentwindow.document.body.offsetHeight + 'px'; location.href='#tag'; }); } }); </script> Link to comment https://forums.phpfreaks.com/topic/271231-iframe-onload-does-not-pass-validation/#findComment-1395799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.