簡體   English   中英

超鏈接在Javascript中沒有響應

[英]Hyperlink not responding in Javascript

我在javascript函數中添加了一個簡單的超鏈接。 它看起來如下:

if (!root.innerHTML.replace(/\s/g, '')) {
                var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");

                root.innerHTML =
                    '<h2>Your browser is not compatible with FlexPaper</h2>' +
                        '<h3>Upgrade to a newer browser or download Adobe Flash Player 10 or higher.</h3>' +
                        '<p>Click on the icon below to download the latest version of Adobe Flash</p> ' +
                        '<a href="https://get.adobe.com/flashplayer" >Enable Flash</a>';

當我運行它時,我的網絡瀏覽器會正確顯示所有內容。唯一的問題是當我嘗試單擊超鏈接時,沒有任何響應。 在過去的一個小時中,我一直在研究以找出原因。 上面的代碼寫在.js文件中,我嘗試在HTML標記內的.jsp文件中實現超鏈接,並且工作正常。

我做錯什么了嗎?

可能是您的瀏覽器阻止了該鏈接?

我只是在下面運行了您的代碼,它對我來說效果很好,因此可能是安全問題。

 function initialise(){ dd = document.getElementById('div_location') dd.innerHTML.replace(/\\s/g, '') var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://"); dd.innerHTML = '<h2>Your browser is not compatible with FlexPaper</h2>' + '<h3>Upgrade to a newer browser or download Adobe Flash Player 10 or higher.</h3>' + '<p>Click on the icon below to download the latest version of Adobe Flash ' + '<a href="https://get.adobe.com/flashplayer" >Enable Flash</a>'; } initialise(); 
 <!DOCTYPE html> <html> <head> <style> body { background-color: #4c4c4a; color: #dbdb67; } input { background-color: #6d6d68; color: #dbdb67; } </style> <title>html replace</title> </head> <body> <br> <br> <div id='div_location'>Let's try making a promise</div> </body> </html> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM