Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

static and dynamic content on a page

My .shtml page has 2 sections: the top displays static html content, and below it, is the section for the random content display with  SSI.


Since I dont want to put the random content section of my page in a frame in order for the top section with fixed content (images,text, etc) to not flicker or blink when refreshing the page,

Can I use a table instead, so it refreshes this part (random content) only?


P.S. hope you understand what i'm trying to say, cause I'm chinese.


Viki


0
cayi
Asked:
cayi
  • 5
  • 4
1 Solution
 
nurbekCommented:
try iframe

<iframe scrolling="no" width="468" height="60" frameborder="0" src="myfile.html"></iframe>
0
 
JohnModigCommented:
I think I know what you mean with "top section with fixed content not flicker or blink when refreshing the page".

You could do it using javascript.
Your page will not flicker or blink.
The code will look something like this:

---------------------------------------
Put this somewhere within your <head> tags:
---------------------------------------

<script language="Javascript">
<!--
function changeContent(ssi)
{
var PrintDiv =  document.getElementById('dynamicContent');
var ContentDiv = document.getElementById(ssi);

PrintDiv.innerHTML = ContentDiv.innerHTML

}
//-->
</script>

---------------------------------------
Put this where you want to show your ssi content:
---------------------------------------

<div id="dynamicContent">
</div>

---------------------------------------
Put this where you want the links to change the ssi content:
---------------------------------------

<a href="#" onClick="changeContent('ssi1')">ssi1</a><br>
<a href="#" onClick="changeContent('ssi2')">ssi2</a><br>

---------------------------------------
Put this in the end of the page (these layers will not be visible, but we will need them to be able to load the ssi files):
---------------------------------------

<div id="ssi1" style="visibility: hidden;">
<!--#include file="ssi_file_1.htm" -->
</div>

<div id="ssi2" style="visibility: hidden;">
<!--#include file="ssi_file_2.htm" -->
</div>

---------------------------------------
Hope it helps, please keep me posted.

John
0
 
cayiAuthor Commented:
Hi John,

In my html code, Given that I already have a Javascript (Automatic target="_blank" Attribute For Links),  I added a target
attribute, so the link to change the ssi content would be the exception. the modified codes are below and my script as well at the end.

<a href="#" target="_top" onClick="changeContent('ssi1')">ssi1</a><br>

<div id="ssi1" style="visibility: hidden;">
<!--#exec cgi="/cgi-bin/MasterMerryGoRound.cgi"-->
</div>



The Script I have at the bottom of the page, above the </BODY> is:

<script type="text/javascript" language="JavaScript">
<!--
function NewWindowAllLinks()
{
   var numlinks = document.links.length - 1;
   for(var i = 0; i <= numlinks; i++)
   {
      document.links[i].target = '_blank';
   }
}
setTimeout('NewWindowAllLinks()',1000);
//-->
</script>


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JohnModigCommented:
Well, is it working or not?
Oh, and btw, you should not have to go through all that just to change the target of the links.
------------------------------------------------
Just put this between your <head> tags:
------------------------------------------------
<base href="" target="_blank">
------------------------------------------------
By declaring a base target you are in affect telling the browser that all links contained within the document will be targeted to the same place, except for the ones that you specify with target attribute, like you did above.
0
 
cayiAuthor Commented:


I replace the script I had before, with <base href="" target="_blank">

As for The link to click to change the content, it seems to work for a one-time only, and for any subsequent clicks thereafter, my browser displays a warning yellow icon stating:

Line: 16
Char: 1
Error: object required
code: 0



Here's the coding that I have before the </body> tag on my page:

<a href="#" target="_top" onClick="changeContent('ssi1')">ssi1</a><br>
<p></p>
<div id="dynamicContent">

<!--#exec cgi="/cgi-bin/MasterMerryGoRound.cgi"-->

<div id="ssi1" style="visibility: hidden;">
<!--#exec cgi="/cgi-bin/MasterMerryGoRound.cgi"-->


P.S. Is the error due to repeating a line?
0
 
JohnModigCommented:
Hmm... It works fine, for me.
On the other hand I do not know what your cgi script is doing so maybe it could be that.

Anyway, that message you got tells us that the problem is at line 16 in your code.
What is at line no 16?
0
 
cayiAuthor Commented:
>What is at line no 16?
I no longer have the error, it has been fixed somehow

I have another problem though, to better ilustrate it,
I've setup a demo page(it's an .html file instead of .shtml) at http://cayi.hostrocket.com

Please See that,
when the "ssi" link is clicked for the second time and  subsequently, nothing happens, that is, it won't load the next content in line for display, unless the browser window is refreshed
0
 
JohnModigCommented:
Hi again cayi, sorry for late reply.
The problem is not the javascript code. The problem is how the cgi script works.
The cgi needs to be reloaded in order to change the html content. So the second time you click the link the javascript copies the html code from the cgi which is then exactly the same code as the one thats already in the visible div. So, the javascript actually works (!) but to the eye, no changes are being made.
Get it?

If you don't it does not really matter, all you need to know is that the above javascript does not fit your purposes, unfortunately.
You have to reload the cgi script in order to make it generate new html content.
Since you do not want to use frames, you'll have to go with iframe instead.
The code should then be something like this:
------------------------------------------

<a href="javascript:parent.ssi1.location.reload()">ssi1</a><br></p>
<iframe name="ssi1" src="ssi_login.htm" width="500" height="200" scrolling="no" frameborder="0">
<!--#exec cgi="/cgi-bin/MasterMerryGoRound.cgi"-->
</iframe>ยด

------------------------------------------
Of course you have to play around with size and styling.
Let me know if it works for you.

John
0
 
cayiAuthor Commented:
Yes, I'll go with Iframe
thank you
0
 
JohnModigCommented:
No problem m8 :)
Glad to help out.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now