Forum Moderators: open

Message Too Old, No Replies

<ifscript> "tag" or equivalent?

Can't use document.write()

         

adni18

9:20 pm on Jun 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, first off I guess you should know that I made a script that uses AJAX to retrieve updated contents from a server-side script, and updated files have page numbers written out in a link (for when there are multiple pages of content).

In the javascript, all I have to really do is change a variable and call a function and the page is changed. This can also be done manually by setting a URL variable.

So my question is, is there a way to write a tag looking something like:

<a href="javascript:void(0)" onclick="cpage='4';reqMDFive('norefresh')">4</a>

if the user has javascript, but if they don't, then fall back on:

<a href="?pg=4">4</a>

?

I know about the <noscript> tag, but the trouble is, the first 4 will still be displayed, so the user will see 44.

If it were the other way around, I would make a script that loops and hides all the other tags, yet I want to hide the tags while javascript is OFF (or not supported).

Is there a <ifscript>the user only gets this if javascript is on</ifscript> tag? I have also tried writing the contents with document.write() but it simply does not work, seeing as the page has already been loaded and all.

I really need to get this problem fixed, please help!

garann

11:28 pm on Jun 16, 2006 (gmt 0)

10+ Year Member



For your link, will this work?

<a href="?pg=4" onclick="cpage='4';reqMDFive('norefresh');return false;">4</a>

The javascript in the onclick should block the link from working, but if there is no javascript, it should just go to the URL specified.

You could also start out with the elements you don't want to show hidden using

style="display:none;"
, then turn them back on with javascript when the page loads.

adni18

11:34 pm on Jun 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks! :D

adni18

12:50 am on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm, are you sure that cancels the link? It's not seeming to work for me.

rocknbil

5:12 pm on Jun 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah that should work. Sometimes you have to reboot the browser after turning off JS to test it, but return false can't execute if there's no Javascript, so it goes to the link.