简体   繁体   English

HTML 中的分页符

[英]page break in HTML

i want to use page break in html that means the reader cannot scroll down further until he select a link for it.我想在 html 中使用分页符,这意味着读者在 select 为其提供链接之前无法进一步向下滚动。

<SPAN id=title><A name=BdToc_1 external=yes><h1 id="BookTitle" align="center"><font color="#B90000"><b>Choose Subject</b></font></h1>
</A>
</SPAN>
<p>
Contents....
</p>

I want a page break before and after this.我想要在此之前和之后分页符。 Please help me请帮我

Forgive me for pointing out the obvious, but page breaks are used to separate distinct pages.请原谅我指出了明显的问题,但分页符用于分隔不同的页面。 Each HTML document is a distinct "page".每个 HTML 文档都是一个不同的“页面”。 "select[ing] a link" traditionally loads a new page. “选择[ing]链接”通常会加载一个新页面。 So.... why don't you just load the next page when they click on this link?所以....当他们单击此链接时,您为什么不直接加载下一页?

You can specify where page breaks occur using CSS properties page-break-after , page-break-before .您可以使用 CSS 属性page-break-afterpage-break-before指定发生分页符的位置。 Of course, this works only when printing the web page.当然,这仅在打印web 页面时有效。 As far as I know, these properties are correctly implemented in all major browsers including IE6+.据我所知,这些属性在包括 IE6+ 在内的所有主要浏览器中都正确实现。 Additionally, you can also state that page break should not occur inside an element using page-break-inside .此外,您还可以使用page-break-inside state 分页符不应出现在元素内部。

If you want paging per se, you need to have HTML for each page and interlink these pages.如果您想要分页本身,则需要为每个页面设置 HTML 并链接这些页面。 Or you can fetch contents of each page using AJAX dynamically, which of course involves scripting.或者您可以使用 AJAX 动态获取每个页面的内容,这当然涉及脚本。

It's not quite possible in HTML.在 HTML 中不太可能。 You could try makeing something in Javascript, but anyone can dissable javascript.您可以尝试在 Javascript 中制作一些东西,但任何人都可以禁用 javascript。

Why would you want something like this?你为什么想要这样的东西?

You can use onscroll in javascript to control the scrolling.您可以使用javascript 中的 onscroll来控制滚动。 The onscroll event can determine the current position and there is a function to scroll up if the user is too far down. onscroll 事件可以确定当前的 position 并且如果用户向下太远,则有一个 function 向上滚动。

Then, when the user clicks the link, you set a flag (scrollok=1).然后,当用户单击链接时,您设置一个标志(scrollok=1)。 The onscroll checks the flag and now permits scrolling. onscroll 检查标志,现在允许滚动。

If you want to defeat people who have deactivated javascript, just make the content invisible until they click using stylesheets: visibility=none.如果您想击败已停用 javascript 的人,只需使用样式表使内容不可见,直到他们单击:visibility=none。

Then, when they click the link, you enable scrolling via the flag, and make the content visible.然后,当他们单击链接时,您可以通过标志启用滚动,并使内容可见。

If you don't know how to do these things, just leave a comment and I can be more precise.如果您不知道如何做这些事情,请发表评论,我可以更准确。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM