View Full Version : HTML Include?
DarknessFalls
07-20-2008, 07:34 PM
I'm looking for something in javascript that would include an html file from another server/address into the code of the webpage only displaying the html and not the javascript so that any links are followable by search engines.
I know something like this exists because there are scripts in this forum for such a thing but all the script links in those threads are broken.
Thanks in advance.
molendijk
07-20-2008, 07:59 PM
Can you tell me which script links are broken? I know there was a problem, but that's solved now.
Anyhow, if you want to include foreign HTML, you have to use iframes. You could do something like this:
<a href="#" onclick="inserted=document.getElementById('SomeDiv');
inserted.style.position='relative'; inserted.style.width='70%'; inserted.style.height='70%';
inserted.style.left='10px'; inserted.style.top='20px'; inserted.innerHTML='<iframe src=\'http://www.google.com\' frameborder=\'no\' style=\'width:40%;height:40%;\'></iframe>'; return false">Google</a>
<div id="SomeDiv"></div>
or replace the appropriate parts of the lines above with css / javascript-functions.
===
Arie Molendijk.
molendijk
07-20-2008, 08:14 PM
There's also this (http://codinginparadise.org/weblog/2007_08_15_archive.html) solution, of which the following is an application:
<head>
<style type="text/css">
a{font-family:verdana; font-size:12px}
#google{position:relative; left:50px; height:280px;width:500px; overflow:auto; border:1px dashed red; display:none}
</style>
<script type="text/javascript" src="http://codinginparadise.org/projects/purple-include/purple-include.js"></script>
</head>
<body>
<a href="#" onclick="document.getElementById('google').style.display='block'; return false">Google</a>
<div id="google" href="http://www.google.nl#xpath(//html)"></div>
</body>.
===
Arie.
The OP said (or so I understand) 'not Javascript, so that the links can be followed by search engines'. In which case, I'm afraid, you are out of luck. No such solution exists at this time. If you're using XHTML (proper XHTML (http://www.webdevout.net/articles/beware-of-xhtml), dropping IE support) you can use XIncludes, but support for XIncludes is, at the time of writing, sparse.
Arie, that's very bad scripting. :-\
molendijk
07-21-2008, 02:11 PM
Arie, that's very bad scripting. :-\
I know. Just a quick way to show how to get Google in a div without (i)frame.
===
Arie.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.