Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DHTML div.innerHTML Source

Posted on 2002-03-10
3
Medium Priority
?
1,275 Views
Last Modified: 2008-09-30
Is there a way to set the innerHTML of a div (i.e. document.all.myDiv.innerHTML) to read from another file. In other words instead of this

  document.all.myDiv.innerHTML = "blah blah blah"

I want to do this

  document.all.myDiv.innerHTML = document.asp?queryvar

Anyway to do this? I tried using SSI's, but it wouldn't let me sub a JS variable into the middle of the include path for whatever reason (kept getting "The include file '/include/PerformerPop.asp?" + performer + "' was not found.").
0
Comment
Question by:Dyrewolf
3 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 6854287
what you have to do is use either a frame or iframe to load the document, then under MSIE5+,
var oHTML = document.getElementsByTagName("HTML");
if (oHTML.length == 1) {
 document.all.myDiv.innerHTML = oHTML.item(0).outerHTML;
}
0
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 400 total points
ID: 6854407
You can only include a physical file using SSI. The include is done on the server side, even before the asp code is executed.

You could use the xmlhttp object to request the page from javascript:

function XMLRemote(url)
{
     var objData=new ActiveXObject("Microsoft.XMLHTTP")
     objData.Open('Get',url, false);
     objData.Send();
     return objData.ResponseText;
}

document.all.myDiv.innerHTML=XMLRemote('document.asp?queryvar');
0
 

Author Comment

by:Dyrewolf
ID: 6859680
Perfect... thanks man
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question