简体   繁体   English

超链接在Javascript中没有响应

[英]Hyperlink not responding in Javascript

I added a simple hyperlink inside a javascript function. 我在javascript函数中添加了一个简单的超链接。 It looks below: 它看起来如下:

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

When I run it, my web browser displays everything correctly.The only issue is when I tried to click on the hyperlink, I get no respond. 当我运行它时,我的网络浏览器会正确显示所有内容。唯一的问题是当我尝试单击超链接时,没有任何响应。 I have been researching for the past hour trying to figure out why. 在过去的一个小时中,我一直在研究以找出原因。 The code above is writen in a .js file and I tried implementing the hyperlink in a .jsp file inside a HTML tag and it works fine. 上面的代码写在.js文件中,我尝试在HTML标记内的.jsp文件中实现超链接,并且工作正常。

Am I doing anything wrong? 我做错什么了吗?

Could it be that your browser is blocking the link? 可能是您的浏览器阻止了该链接?

I just ran your code below and it works fine for me so it may be a security issue. 我只是在下面运行了您的代码,它对我来说效果很好,因此可能是安全问题。

 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