Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change the source of a page... 1

Status
Not open for further replies.

Tels

IS-IT--Management
Jul 10, 2001
290
GB
I have a page which utilises a floating menu (layers)
The menu has various pull-outs etc, and links.
I want to be able to change the source of the page (everything behind and beneath the menu layer) without actually re-loading the layers themselves (this would re-set the menu state and take up extra time to re-load the images)

I have experimented with frames (intention: an invisible frame to hold the DHTML layer code, but the layer doesn't appear outside the parent frame(is there a way to do this??)), tried using an inline scroll box (ok but looks shabby...) I have tried lots of stuff but all I want is for the menu layer to stay put whatever link is pressed.

I can and will supply the source script if you need it

Tels Mixed Linux/Win2000 Network Administrator
 
you can use element.innerHTML property to change the HTML of the page

<table><tr>
<td id=TDTag>hello</td></tr></table>
<a href=&quot;#&quot; onclick=&quot;ChangeHTML(); return false&quot;>change me</a>
<script language=javascript>
function ChangeHTML() {
TDTag.innerHTML = &quot;<a href=\&quot;#\&quot; onclick=\&quot;alert('good bye')
\&quot;>good bye</a>&quot;
}
</script>
 
I see exactly what you mean....I notice I'll have to make extensive use of \escape characters, what characters need to be escaped, or is there a tool which can parse and convert the data automatically?

Thanks sjravee... looking forward to your reply
Tels Mixed Linux/Win2000 Network Administrator
 
...To perhaps try a slightly different angle, is there any way of setting up a layer which rides on top of any frames, I have tried to add the script to the framset page but no luck there so far....
8)
Tels
Mixed Linux/Win2000 Network Administrator
 
this is the main page:
<html>
<frameset cols=&quot;100%,0%&quot;>
<frame id=&quot;content&quot; name=&quot;content&quot; src=&quot;software.asp&quot;>
<frame id=&quot;frmcode&quot; name=&quot;frmcode&quot; src=&quot;tcode.asp&quot;>
</frameset>
</html>


The content page &quot;software.asp&quot; has a function that sets an innerHTML of a label of div on the content page. This function is called by the frmcode page. The function looks like this:
function showcontent(strvalue){
lbl.innerHTML=unescape(strvalue);
}

Now for the frmcode page &quot;tcode.asp&quot; I just fill out the html in a <textarea> (server script) and pass that value escaped to the showcontent function (client script) in the content page like so:


<html>
<body>
<form id=&quot;frm&quot;>
<textarea ID=&quot;values&quot; NAME=&quot;values&quot;><table cellspacing=1 width=100% >
some value here including html tags but not the textarea tag if you have a /textarea tag replace the
< with unescape value (& # 6 0 ;) but without the spaces. Hey this is allso displayed in an HTML browser.
 
Harmmeijer, thanks for replying

I don't know that asp will work that well as all my content is served from *nix.. (I just can't be bothered to stress out over Windows' buggy, patchy, basically naff security... I'm now a Linux junkie... :) grin)

I don't quite grasp all you say, but I think what you mean is that, rather than containing the layer code directly in the top frame, have the layer code inserted into the innerHTML of each new top frame by an ever-present invisible bottom frame.... novel & I am going to try it out.

I realise I might not be able to use ASP, maybe there is another solution, such as a <body onload=&quot;onload()&quot;> in the bottom frame... would this refer to the parent window, or the top-level window?

Thank you again..
Really appreciate your quick replies

Tels Mixed Linux/Win2000 Network Administrator
 
Hi Tels,

<body onload=&quot;onload()&quot;> would refer to the frame that contains the body tag.

I have used frames because some of the content is dynamic because of the asp code (could allso be php or other server script).

The idea is that if you need to get info from the server the whole page wil reload every time you request some info. To prevent that I submit info to a hidden frame, let the server script fill out the dynamic content in a <textarea>, put the content from the <textarea> in the visible frame with client script.
I see that in my pref post the tcode.asp is not complete, here is the complete version:



<html>
<body>
<form id=&quot;frm&quot;>
<textarea ID=&quot;values&quot; NAME=&quot;values&quot;><table cellspacing=1 width=100% >
some value here including html tags but not the textarea tag if you have a /textarea tag replace the
< with unescape value (& # 6 0 ;) but without the spaces. Hey this is allso displayed in an HTML browser.
</textarea>
</form>
<script language=&quot;javascript&quot;>
setcontent();
function setcontent() {
try {
parent.frames.item('content').eval('showcontent(\'' + escape(String(frm.values.value)) + '\',0)');
}
catch(errorObject) {
setTimeout('setcontent()', 500);
}
}
</script>
</body>
</html>



If you do not need dynamic content (info provided by server side script) you can put a view invisible <div>'s in your html (style=&quot;visibility: hidden;top: -1000;position: absolute&quot;) and set the innerHTML of a visible div whith that of an invisible div when a button is clicked or some other event.
 
Although I have some way to go before I can use all this, I think you deserve a star, Harmmeijer..... Mixed Linux/Win2000 Network Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top