2013-07-07 171 views
0

我有一個頁面,我已經編程了聖經的順序訪問,每個詩句都包含一個鳴叫按鈕。跳轉到推特鏈接頁面上的位置

當我推送詩句時,鏈接重定向到詩句頁面,但從頂部開始。

我想要的是,當tweet鏈接被點擊時,它會進入經文頁面,然後跳轉到該頁面上的經文位置。

這可能嗎?你能幫我嗎?

這是我當前的代碼:

<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> 

回答

1

謝謝奧雷斯特斯和帕維爾,這是我做的;我改變了以下內容:

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>"; 

它現在的作品!

0

完全。您需要您想要滾動到的HTML元素的ID。假設你有一個ID爲'verseToScrollTo'的div。在網址末尾追加#verseToScrollTo將使頁面在頁面加載時自動滾動到該位置。

相關問題