Solved

DHTML div.innerHTML Source

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now