Solved

display contents from other urls within my pages

Posted on 2004-04-25
16
393 Views
Last Modified: 2010-04-06
Hi
here is the senario. i have a client that needs to display other sites contents within his pages. following what i have tried and why it did not work.
1- using frames is bad idea and the client do not like it as the header and footer causing for sure scrolling in the contents and in a small area too. so that is not an option unless there is a way to display all the contents as one page without scrolling
2- i have tried iframes with auto resize. the problem that i can not find that it has been solved or maybe it can not be solved is cross-site scripting security that pervents geting the document hight in the iframe to resize it and results the permmision error. i have tried a dhtml script http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm but as mentioned it will get errors if used with urls out of the same domain.
3- grabing the text with php or asp results the page images and links to be broken. i have tried to add <BASE href='URL'> to correct the errors but that did not correct all relative links and images. also it did not work for javascript menu.
that is the situation and all what i have tried. I am open to any server side or client side that will enable me to dispaly the header+ contents from other url(actuly the whole page without any changes)+footer.
thanks for all your help
0
Comment
Question by:mohmedsh
  • 8
  • 5
  • 3
16 Comments
 
LVL 6

Expert Comment

by:pkaleda
ID: 10918478
You can use your ASP methode and programatically replace the href and image tags to include the referring domain in the code with replace.

Here is a sample:


<SCRIPT LANGUAGE=vbscript RUNAT=Server>
Function GetHTML(strURL)
on error resume next
  Dim objXMLHTTP, strReturn
  Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")

  objXMLHTTP.Open "GET", strURL, False
  objXMLHTTP.Send    
  strReturn = objXMLHTTP.responseText
  Set objXMLHTTP = Nothing

  GetHTML = strReturn
End Function
</SCRIPT>

<%
                  
'Define URL
myurl = "http://www.domain.com/directory1/index.html"
URLpath = "HTTP://www.domain.com/directory1/"

'Retreive URL
retval = GetHTML(myurl)

'Source Replacement
Source = replace(server.HTMLEncode(retval),chr(13),"<br>")
Source = replace(source, "href=", "href="&URLpath")

Response.write(source)
%>
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10920448
You can try populateing a layer with XMLHTTP directly in the page.

You can use this script to bring external page into a layer in the page and let it size dynamically.  If necesary you should also be able to size and position the layer even after it is populated; but you still won't be able to script the target page.

<script language='JavaScript'>
<!--
function include(lyr,url)
{
   if (document.all)
   {
      // IE version
      try {
      var xml = new ActiveXObject("Microsoft.XMLHTTP");
      // some versions of IE4 and some IE5.0) might be using MSXML2.XMLHTTP.4.0
      xml.Open( "GET", url, false );
      xml.Send()
      document.getElementById(lyr).innerHTML=xml.responseText;
       }
      catch (e) {
      var xml = new ActiveXObject("MSXML2.XMLHTTP.4.0");
      xml.Open( "GET", url, false );
      xml.Send()
      document.getElementById(lyr).innerHTML=xml.responseText;
      }
   }
   else
   {
      // Mozilla/Netscrap 6+ version
            var xml=new XMLHttpRequest();
            xml.open("GET",url,false);
            xml.send(null);
            document.getElementById(lyr).innerHTML=xml.responseText;
   }
}
//-->
</script>
You can trigger the script off the load:
<body onLoad="include('somediv','http://somepath/somefile.html'">
where somediv looks like: <div id="somediv">&nbsp;</div>

Or dynamically from a link:
<a href="#" onClick="include('somediv','http://somepath/somefile.html');return false">
   load alternate page
</a>

or inline as a conventional include:

<script language='JavaScript'>
   document.write('<div id="somediv">&nbsp;</div>');
   include('somediv','http://somepath/somefile.html');
</script>

If the string returned from the call contains valid HTML it will be rendered, otherwise it will display as plain text.

Does not work for older browser like Netscrap 4.x that do not know what XML is.

It can produce an alert if the user security settings have activeX disabled

Not the the url MUST be full qualified.

You have to actually test it across to a http server; it won't work just on the local file system.

Cd&
0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10924043
pkaleda, you have added urlpath to my idea , it is good idea and through i can get the apsulate path of any images orlinks. But what about javascript links and menues, how would i deal with them?
COBOLdinosaur , I perfer using XMLHTTP on server side but here we are again what about links , images, javascript menues and javascript links in the url. how to provide working page without beoken items.
iframes was so good concept and i do not understand how it was working perfectly in my browser and resizing the page dynamically to any loaded page for 5 days without problems. Now it is not working in any browser but only mine :)
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10928660
mohmedsh,

You are looking for an ideal solution that does not exist.  When you use external content that you do not control there are limitations.  There is also no guarantee that anything you get working will continue to work, because you cannot control, and may not even know about changes in the coding of the source pages.

If your client wants to grab pages from other sites then they need to know that the rendering is in the control of the source site.  You could pull down everything you need server side and generate the pages dynamically.  However if your client does not have permission from the sites to do that , then they may block your clients IP.

Of all the options iframe is the best, and if the client does not like the scrolling then tell them to make arrangements with the source sites to put code in the page to do the re-sizing of the window.  

Cd&
0
 
LVL 6

Expert Comment

by:pkaleda
ID: 10929124
One other point to make.  You can spend 3 days coding to make it work and then when they revise their pages code a little, you have to recode all yours to make them work again.  

You also have to think of the legal issues with redisplay.  Do you have permission?  do they have a copyright?  
0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10929806
Here is the exact situation. I am not dealing with contents from other sites that is general like news, articales and so on. My client is an agent for those manufactures, They do not want to make a dbase to add the products from each manufactor as they may change , more added or more information available. They want to display all the information directly from the manufactures' sites , the data i will display will include the whole page with logos and other materals from the manufactures' sites. they already have permission to use the contents.
0
 
LVL 6

Accepted Solution

by:
pkaleda earned 400 total points
ID: 10930169
The best solution will be either a frame page or iframe page.  Problem with the Iframe solution is they would have to include javascript code to tell our page what the size is.  I would suggets you use a header main body frame solution.
0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10930222
Sorry COBOLdinosaur , i did not know how to choose assisted answer. can you please tell me how to correct this? may i do another Q for points or what.
Thanks all for your help
0
 
LVL 6

Expert Comment

by:pkaleda
ID: 10930242
I will post points for Cobol.

0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10930243
pkaleda, I have no choice as you mentioned. I can not ask others to redesign their sites. I have only one option left that i tried to avoid, i have to use frame header.
Thanks
0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10930306
no pkaleda, just tell me how to post the points. I did not do it before.
0
 
LVL 6

Expert Comment

by:pkaleda
ID: 10930415
I already posted them.  if you want me to cancel it, let me know.  now that this is answered you cannot split the points.  you would have to open a question called points for cobol like I did.
0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10930497
Thanks pkaleda, cancle your points and i will post one.
0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10930534
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10933318
I added a comment in the points for Q that might give us an additional option, if any want to continue the quest for solutions. :^)

Cd&
0
 
LVL 1

Author Comment

by:mohmedsh
ID: 10933651
actulay i am looking for soluation but it looks like there is no one. that is the limits we can work around as we do not have control over other sites' pages.
any way i will keep the other open till tomorow, maybe we get a trick while we are working :)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

776 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