...

View Full Version : loading a page dependant on conditions



johncraw
06-25-2009, 03:49 PM
I am developing a course. I would like to display certain pages, depending on the Operating system.
I do not think that javascript can load a page. So I have tried the following:
In html I have:
[CODE]
<a class=header-button href=nextpage()>
Next
</a>
[CODE]

In javascript I have:
[CODE]
function nextpage()
{
return "WTL01S02aa.html";
}
[CODE]

The above was just to see if it would work.
When I click on the link I get an error that it could not find nextpage()

I have tried the simplest solution. It did not work. Is there a solution?
Thanks in advance
John

Actinia
06-25-2009, 04:14 PM
Your problem is that you have mixed Javascript and HTML. You could use something like:
<a class=header-button href="javascript:nextpage()">Next</a> but this is deprecated.

Much better to use:
<a class=header-button href="#" onclick="nextpage();">Next</a>

Your function nextpage needs to change the document location, not just return a URL.

function nextpage()
{
document.location="WTL01S02aa.html";
return false;
}
The return false cancels the href attribute.

This code has not been tested, I do not have my references to hand. You should check on the exact syntax of document location.

John

johncraw
06-26-2009, 01:16 AM
Thank you. That is exactly what I needed. Throughout the course I use links to move from page to page. I would like to avoid mixing with buttons.
The function works perfectly.
John



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum