Solved

DHTML div.innerHTML Source

Posted on 2002-03-10
3
1,250 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 100 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

786 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