Forum Moderators: not2easy
In some websites when I have a mouse pointer hover on a link , a layer automatice show up displaying more information without having to load a new page. One of the technic I can think out is to use the css display property like the code below
<div style="position:absolute; display:none">......</div>
Then use the javascript to change the style according to user action to make it visible or hidden again. But with this technic, it would be a very ugly page in old browers which don't support "display:none" as all the hidden contents will be visible when the page is loaded.
Another technic is to use the javascript to dynamically generate the layer e.g. using document.write() method. But this would make the script very complicate and also the search engines can't crawl the dynamic generated contents.
So I wonder what is the technic that they actually used in most big sites to work around this issue.
This works with older browsers but the down-side is it leaves a big block of empty space where the div/object is. But if it's as I suspect (revealed by the use of the word 'layers'), you are using z-index and absolute positioning anyway so this problem is irrelevant.
I havn't planed yet where exactly on my sites I will use it. Just thinking about applying more dynamic html trick to my website. Until now I have never apply any dynamic trick to my websites except the back-end administration area which I know for sure what browsers our staffs use.
Your techinque is better. I checked with the reference now and saw that position:absolute, z-index and visibility:hidden are all supported in NN4 and IE4. Maybe it's the time to stop thinking about browsers older than version 4 now.
OK, thanks again.
Just thinking about applying more dynamic html trick to my website.
Before taking this step, consider if it's really worth the effort: will these dynamic tricks make it easier to access the content?
Your problem is pretty easy to solve, really. What you want is an ordinary link to a page that has the content you want to display. Your JS should
This method will work for any browser, whether or not javascript is available. If you want to see an example of a script that works precisely this way, try this search [google.com].
-b
Thank you for your tricks. But I think loading the content up on user action may too slow. As I said in my original post that another method is to using document.write (or writing the innerHtml property). By this way I can check the browser or object before generating the hidden layer.
The problem of this method is that, instead of writing the simple html code , now, the html code must be contained in the javascript string. So I have to make sure that I've add the back slashs to all special characters properly.
It would become even more complicate task when I generate these client-side script with php script. That means the client-side script (which generate the html code) now need to be contained within a php string. A lot of back slashs to add now.