bobzrz8
bobzrz8

Reputation: 129

When clicked somewhere on a certain webpage, open a new page(like a link)

I would like to make the whole webpage, index.html for example to act as a link. Wherever you click it would open a new tab/window with the specified url. After it has been clicked, let the user do whatever he wanted to do. I would also like to make the page act like a url from 12 to 12 hours, also a specified time. I don't know how to start, I hope that somebody will point me in the right direction.

Thanks

Upvotes: 1

Views: 204

Answers (1)

Rhyono
Rhyono

Reputation: 2468

Assuming I properly understood your question: you probably want to do this to force them to follow an ad or something.

To make the entire page a link: use a div with a width and height of 95-100% (using 100% in some browsers will cause the page itself to expand a little) as well as making the div's position absolute. This will act as an overlay and essentially force them to click on it. Wrap the div in an anchor tag with a target of "_blank" or add an onclick to the div which executes JavaScript that does the same thing.

The onclick method is probably better since you also want the onclick to set the div's display to "none" in order to let them continue doing whatever on your site.

Wanting to only do it between a certain time frame would require using JavaScript to fetch the local time for that person (you can also fetch their time zone in order to convert it to your own time zone) and then determine if it is between the time frame you want the overlay to appear. If it is, it will set the div's display to "" or "block", otherwise the div will remain as "none"

Upvotes: 1

Related Questions