Hi Trevor, First of all a big thank you for trying to help a novice.
On my website I have several links to hotel descriptions which open on a _blank page.
Such a link is as shown below
<a href="
http://212.161.124.21/ob/hotel_desc.asp?HID=20051111120903108689&Lang=EN"
target="_blank">More info</a>
What I'm trying to achieve is to get the hotel description to open up on another page
which has a header and footer instead of a blank page.
I'm not sure if I misled you before but I think I need to add some script/code to the
front of the a href so that it directs it to the results page where it will be
displayed. I suppose I'm looking for a way to get a page to open within a page if that
makes sense. Please help if you can. Fred
Well, you can tailor which page you call into the iframe
<button onclick="loadIframe('News','news.html')">Open/Close News of this Site</button>
<iframe class="c1" id="News" src=""></iframe>
function loadIframe(id,sPath)
{
var x = document.getElementById(id)
if (x.style.display != 'block')
{ x.src = sPath
x.style.display = 'block'}
else
x.style.display = 'none'
}
The parameter sPath (e.g. 'news.html') determines which page gets loaded.
The problem now is passing this parameter into the page. I recently posted on a similar query
(or at least my answer was similar)
Call the page like this
<html>
<head></head>
<body>
<a href="results.html?page=news.html">call news</a>
</body>
</html>
This is results.html
<html>
<head>
<script type="text/javascript">
function qsobj(parm)
{
var qpairs = document.location.search.substring(1).split("&")
var qvbl = qpairs[parm].split("=")
return qvbl[1] ? unescape(qvbl[1].replace(/%20|\ +/g," ")) : null
}
function loadIframe(id)
{
var sPath = qsobj(0)
var x = document.getElementById(id)
if (x.style.display != 'block')
{ x.src = sPath
x.style.display = 'block'}
else
x.style.display = 'none'
}
</script>
</head>
<body>
<button onclick="loadIframe('News')">Open/Close News of this Site</button>
<iframe id="News" src=""></iframe>
</body>
</html>
I have tested this and it works.
But there is still a button on results.html which you have to click.
If you want it to load automatically, use this in the <body>
<body onload="loadIframe('News')">
<iframe id="News" src=""></iframe>
</body>
If I have misunderstood what you want, please let me know and I will have another try
Fred wrote:
Hi Thor, Unfortunately I need the trickier option. I need to put the
cart before the horse with this one. I need to try and find a way for
the <a href to include the destination (results) page plus the usual
hyperlink. I've seen this done but can't remember where. Fred
Here's a simple approach, if it will meet your needs:
Put your news item text on a page such as "news.htm." Call the
news.htm page from the iFrame, set into the Special Results page. Then your hyperlink calls
the special results page, with whatever
text you want surrounding the news item, and the frame calls the
news page. Like so: <body>
<p>This is the results page. In the center is the news
item.</p> <p> </p>
<p>
<iframe name="New Information" src="news.htm" width="350"
height="200" align="center"></iframe>
</p>
</body>
The only "catch" is that your subject matter must be placed in the
news.htm page first. If you want the iFrame to open a variety of page
names, that would be much trickier.
Is it possible to set up a hyperlink so that it opens up in a
special results page. I need to be able to set up the results page
so that the subject matter (the hyperlink) opens in a pre-defined
iFrame in the centre of the results page. TIA. Fred