Jump to content

Java if/else statement with time


mcmuney

Recommended Posts

I need a javascript if/else statement that will be placed on an IMAGE LINK. On click, it will check to see if the users date/time falls in a weekend (Sat and Sun).

 

-If it does, it will continue to the hyperlink and load the page.

-If it does NOT fall in a weekend, it will check to see if it's between the hours of 9-10.

-If it is then it will continue to the hyperlink and load the page.

-If it is NOT, then it will load a different page.

 

I've searched and searched the net, but couldn't find anything close. Thanks in advance.

Link to comment
Share on other sites

code your link like this:

<a href="the url" onclick="return checktime();"><img src="url"></a>

the checktime() routine will be coded to return either true or false depending on the time tests:

<script>
function checktime() {
    // time test checks
    if (timeOk) {
        return true; // causes the original href to be followed
    }
    return false; // the original href will not be followed
}
</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.