2015-12-07 104 views
0

I'm trying to link to a book on Amazon. I've boiled it all down to a very simple piece of code which does not take me to Amazon when I click on the link. If I just put the address into a browser then the page loads fine. How can something so simple not work?很簡單<a href link not working

<!DOCTYPE html> 
<html> 
<body> 

<p><a href="http://rads.stackoverflow.com/amzn/click/093849743X">Amazon Link</a></p> 

</body> 
</html> 
+0

「A tryit編輯的代碼」在您的網站的鏈接,您可以用iframe它的作品在我的電腦罰款... ?!那是什麼意思? – deceze

+0

對不起。使用英語不好。我的意思是說,我正在嘗試使用在線服務中的代碼,您可以粘貼代碼並「嘗試」。 – user740360

+0

這是一個重要的上下文信息,您應該澄清而不是刪除。 – deceze

回答

3

It's because most webpages don't allow you to display them in frames. If you open the JS console of your browser you will see something like

Refused to display 'http://www.amazon.com/dp/093849743X/?tag=stackoverfl08-20' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. 

Just save it as a .html file on your pc and run it. The link will work.

More information: How to set 'X-Frame-Options' on iframe?

0

好,如果你想顯示在你的代碼一樣

<iframe src="www.google.com" height="500" width="500"></iframe> 
相關問題