Solved

display contents from other urls within my pages

Posted on 2004-04-25
16
384 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:pkaleda
Comment Utility
I will post points for Cobol.

0
 
LVL 1

Author Comment

by:mohmedsh
Comment Utility
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
Comment Utility
no pkaleda, just tell me how to post the points. I did not do it before.
0
 
LVL 6

Expert Comment

by:pkaleda
Comment Utility
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
Comment Utility
Thanks pkaleda, cancle your points and i will post one.
0
 
LVL 1

Author Comment

by:mohmedsh
Comment Utility
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

772 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

11 Experts available now in Live!

Get 1:1 Help Now