简体   繁体   中英

Hyperlink not responding in Javascript

I added a simple hyperlink inside a javascript function. 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.

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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM