khushboo.singh Posted June 16, 2014 Share Posted June 16, 2014 how to change the content of div tag by another html file externally using javascriptin my HTML file i want to cange content of div tag "hello freinds" with another file content i.e image.html without opening new tab<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>Amazon</title><link rel="stylesheet" href="amazon.css" /> </head><body> <a href="http://www.microsoft.com" id="one" onMouseOver="return submenu('first','inline');" onMouseOut="return submenu('first','none');">Menu 1</a><br /> <a href="http://www.vnnotech.com" onMouseOver="return submenu('second','inline');" onMouseOut="return submenu('second','none');">Menu 2</a><br /> <a href="#" onclick="hi('third');" >Menu3</a> <div id="first"> This is first div </div> <div id="second"> This is second div </div> <div id="third"> hello friends </div><script>function submenu(item, visibility) {document.getElementById(item).style.display = visibility;return false;}function hi(item1){var newContent="http://localhost/project/image.html";document.getElementById(item1).innerHTML="image.html";return false;}</script></body></html> Link to comment Share on other sites More sharing options...
Day Posted June 18, 2014 Share Posted June 18, 2014 This isn't something you can do with javascript unfortunately. You will need to use a server side scripting language such as PHP or ASP to use includes. The only way to do it without server side scripting languages would be with iframes, which I've done here: http://jsfiddle.net/RDay/DhUa8/ Link to comment Share on other sites More sharing options...
khushboo.singh Posted June 19, 2014 Author Share Posted June 19, 2014 I tried this by using Ajax and got output. hey your document is also help me. Thanks for taking interest in my post Link to comment Share on other sites More sharing options...
dsonesuk Posted June 19, 2014 Share Posted June 19, 2014 jquery $("#TargetElement").load("otherpage.html"); Link to comment Share on other sites More sharing options...
davej Posted June 19, 2014 Share Posted June 19, 2014 how to change the content of div tag by another html file externally using javascriptin my HTML file i want to cange content of div tag "hello freinds" with another file content i.e image.html without opening new tab ??? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now