Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DHTML div.innerHTML Source

Posted on 2002-03-10
3
Medium Priority
?
1,269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

730 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