简体   繁体   中英

Web Browser is Adding Text to my HTML Link

So I'm working with this code:

<script>
var panel1 = Math.random()
</script>
<a href="//files.explosm.net/rcg/" target=_blank onclick="location.href=this.href+panel1+panel1+panel1+'.png';return false;">Repetitive Comic</a>

But whenever I click on "Repetitive Comic" I get sent to a url with the format of "file://files.explosm.net/rcg/*.png" which has an unexpected "files:" in front of it that I don't want. Is this something that my code is doing that I don't know about or is it my browser(Google Chrome)?

You must be running this as a local HTML file, not accessed over HTTP. So any URL starting with:

//

...is going to inherit the same "protocol" as your local file, in this case file:// .

Prepend http: or https: if you don't want file://

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