•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,745 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 5007 | Replies: 4
![]() |
I am trying to a page load an external website's page within a div, but it's just not working....
Anyone got any ideas?
I do know it's possible:
http://orangoo.com/labs/GreyBox/ -- loads google.com in a popup
Here's my code
Anyone got any ideas?
I do know it's possible:
http://orangoo.com/labs/GreyBox/ -- loads google.com in a popup
Here's my code
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="s1/style.css" type="text/css" rel="stylesheet">
<link href="style.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""
function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
{
document.getElementById(containerid).innerHTML=page_request.responseText;
}
else
{
document.getElementById(containerid).innerHTML="<center><img src='load.gif' /><br>"+ page_request.statusText +"</center>";
}
}
function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
</script>
</head>
<body onload="javascript:ajaxpage('http://www.google.com/','RESX'); ">
<div id="container">
<div id="RESX">
<div>
</div>
</body>
</html> You have at least 3 troubles there:
1. Possible copyright law violation if you don't have permission to use the materials.
2. A security violation. All files for a given page must usually come from the same server. Unless the user and the ISP severely reduce their security settings, anything else is suspected as malicious code by the security features.
3. Windows and frames are made to contain web pages. Div tags are not. You will have to strip the file to only some inner-body content to display it in a div. A popup is a window, not a div.
1. Possible copyright law violation if you don't have permission to use the materials.
2. A security violation. All files for a given page must usually come from the same server. Unless the user and the ISP severely reduce their security settings, anything else is suspected as malicious code by the security features.
3. Windows and frames are made to contain web pages. Div tags are not. You will have to strip the file to only some inner-body content to display it in a div. A popup is a window, not a div.
Last edited by MidiMagic : Nov 15th, 2007 at 2:45 am.
Daylight-saving time uses more gasoline
The script came from a tutorial site and I kept the copyright notice (says it can be used as such)
Guess I found out about the security part.
Any ideas on how to modify a page's content after it is loaded into an iframe? or at least get a portion of the page loaded in the iframe?
Guess I found out about the security part.
Any ideas on how to modify a page's content after it is loaded into an iframe? or at least get a portion of the page loaded in the iframe?
Thank you. Seems it's a standard across browsers not to allow scripts from different domains to interact.
Here is a link I found interesting:
http://www.dyn-web.com/dhtml/iframes/
Here is a link I found interesting:
http://www.dyn-web.com/dhtml/iframes/
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Loading External Pages (IT Technologies and Trends)
- How to add Meta Tittle Tags in different website pages (ASP.NET)
- Add more Meta Tittle in different website pages (Search Engine Optimization)
- Link to page in page (HTML and CSS)
- website password protection (JavaScript / DHTML / AJAX)
- HELP ME! Troubles with swf in levels loading css and xml. (RSS, Web Services and SOAP)
- Loading External Pages (Site Layout and Usability)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: javascript null..is it a string?
- Next Thread: ajax POST checkboxes



Linear Mode