0

我有一个页面,我在其中对圣经的顺序访问进行了编程,每节经文都包含一个推文按钮。

当我发推文时,链接会重定向到 verses 页面,但从顶部开始。

我想要的是,当点击推文链接时,它会转到 verses 页面,然后跳转到该页面上的 verse 位置。

这可能吗?如果可以,你能帮帮我吗?

这是我当前的代码:

<html>
<title>The Bible (Sequential)</title>
<font face="arial">
<?php
define ('HOSTNAME', 'host');
define ('USERNAME', 'user');
define ('PASSWORD', 'pass');
define ('DATABASE_NAME', 'db');

$db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die ('I cannot connect to 
MySQL.');

mysql_select_db(DATABASE_NAME);

$query = "SELECT id,book,cap,verse,line FROM bible_kjv ORDER BY id LIMIT 0, 30 ";

$result = mysql_query($query);
while ($data_fetch=mysql_fetch_array($result)) {

echo "<p>", ($data_fetch['book']), " ", ($data_fetch['cap']), " ",    
($data_fetch['verse'])," </p>";
echo "<p>", ($data_fetch['line']), "</p>";

echo "<a href='twitter.com/share' class='twitter-share-button' data-url='bible-query- 
seq-1.php?id=$data_fetch[id]' 
data-text='The Bible (Sequential): http://mysite/bible-query-seq/bible-query-seq-1.php? 
id=$data_fetch[id]'>Tweet</a>";

echo "<hr>";

}

mysql_free_result($result);
mysql_close();
?>

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)  
[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)) 
{js=d.createElement

(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore
(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

<center><a href="bible-query-seq-2.php">Page 2</a></center>
</font>
</html>
4

2 回答 2

1

谢谢Orestes和Pavel,这就是我所做的;我更改了以下内容:

echo "<p>", ($data_fetch['book']), " ", ($data_fetch['cap']), " ",    
($data_fetch['verse'])," </p>";
echo "<p>", ($data_fetch['line']), "</p>";

echo "<a href='twitter.com/share' class='twitter-share-button' data-url='bible-query- 
seq-1.php?id=$data_fetch[id]' 
data-text='The Bible (Sequential): http://mysite/bible-query-seq/bible-query-seq-1.php? 
id=$data_fetch[id]'>Tweet</a>";

至:

echo "<p>", "<a name='$data_fetch[id]'>", ($data_fetch['book']), " ",    
($data_fetch['cap']), " ", ($data_fetch['verse'])," </p>";
echo "<p>", ($data_fetch['line']), "</p>";

echo "<a href='twitter.com/share' class='twitter-share-button' data-url='bible-query-  
seq-1.php?id=$data_fetch[id]' 
data-text='The Bible (Sequential): http://mysite/bible-query-
seq/bible-query-seq-1.php?id=$data_fetch[id]#$data_fetch[id]'>Tweet</a>";

现在它可以工作了!

于 2013-07-08T04:56:47.353 回答
0

完全。您需要要滚动到的 HTML 元素的 id。假设你有一个 id 为 'verseToScrollTo' 的 div。在 URL 的末尾附加#verseToScrollTo将使页面在页面加载时自动滚动到该位置。

于 2013-07-07T19:43:11.587 回答