I just want to load an html page in iframe on clicking a link or button in the same page. I used javascript to load the page dynamically. But, I couldn't do that. Please anyone guide me to do that. My code is as follows:
document.getElementById("iframeelem").src="newhtml.jsp";
I just want to load an html page in iframe on clicking a link or button in the same page. I used javascript to load the page dynamically. But, I couldn't do that. Please anyone guide me to do that. My code is as follows:
document.getElementById("iframeelem").src="newhtml.jsp";
Share
Improve this question
asked Feb 28, 2011 at 13:52
Developer404Developer404
5,97217 gold badges69 silver badges104 bronze badges
1
-
3
try this
window.frames[iframeName].location = url;
and see what happenes, and assign the url as absolute url likehttp:www.something./newhtml.jsp
– KJYe.Name Commented Feb 28, 2011 at 13:55
3 Answers
Reset to default 4Put this on the embedded page
<p>
<input type='button' name='Next' value='Next Page'
onclick='window.location.replace("http://timecrystal.co.uk/");' />
</p>
Your code is correct. Here is a tutorial, just in case: http://www.dyn-web./tutorials/iframes/
What is the error?
Verify the id of your frame and url are correct (type in the url in a browser window and make sure you get your page).
See here. A great help :
- Loading pages in iframe dynamically
Though a bit off topic, a good side reading :
- Loading external sites into Iframe dynamically - is there a better way??
- How to dynamic load the document content into an iframe?