简体   繁体   English

当单击某个网页上的某个位置时,打开一个新页面(例如链接)

[英]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. 我想将整个网页(例如index.html)用作链接。 Wherever you click it would open a new tab/window with the specified url. 无论您在哪里单击它,都将使用指定的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. 我还想让页面在12到12个小时(也就是指定的时间)内像网址一样起作用。 I don't know how to start, I hope that somebody will point me in the right direction. 我不知道如何开始,我希望有人会指出正确的方向。

Thanks 谢谢

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. 要使整个页面成为链接,请执行以下操作:使用宽度和高度为95-100%的div(在某些浏览器中使用100%会使页面本身稍微扩展一点),以及将div的位置设为绝对。 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. 将div包裹在目标标记为“ _blank”的锚标记中,或向div添加onclick,该div执行执行相同功能的JavaScript。

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. onclick方法可能更好,因为您还希望onclick将div的显示设置为“ none”,以便让他们继续在您的网站上执行任何操作。

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. 想要只在某个时间范围内执行此操作,则需要使用JavaScript来获取该人的本地时间(您也可以获取他们的时区,以便将其转换为自己的时区),然后确定时间是否介于该时间之间想要叠加层出现的框架。 If it is, it will set the div's display to "" or "block", otherwise the div will remain as "none" 如果是,它将div的显示设置为“”或“ block”,否则div将保持为“ none”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检测何时单击链接,在新框架中打开 - Detect when link is clicked, open in new frame 右键单击超链接/操作链接/链接按钮时,未出现“在新选项卡或页面中打开” - 'Open in New Tab or Page' not appearing when Hyperlink/Action Link/Link Buttons are right-clicked 滚动到页面底部时,如何像单击链接一样打开新页面 - How to open a new page as if a link was clicked when you scroll to the bottom of page 在新页面中打开图像并在单击时打印 - Open images in a new page and print when clicked 有没有办法在单击某个链接时自动打开选项卡? - is there a way to automatically open a tab when a certain link is clicked? 链接(带有重定向)将以隐身方式打开,或在新标签页中打开,或者显式声明新页面。 只是单击不起作用 - Link (with redirects) opens in incognito or when open in new tab, or new page is explicitly declared. Doesn't work when just clicked 当单击JavaScript和HTML时如何使链接打开新窗口? - How to make a link open a new window when clicked in JavaScript and HTML? 如何在单击链接时打开新选项卡或窗口? - How can I open a new tab or window when a link is clicked? 如何在JSF页面中单击行时打开新页面? - How to open a new page when row is clicked in a JSF page? 从其他页面单击链接时打开特定选项卡 - Open specific Tab when link is clicked from another page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM