简体   繁体   中英

bootstrap button onclick and location.href

有什么理由不行吗?

<button class="btn btn-primary btn-lg" onClick="location.href='http://anothersitehere.com/file.pdf'">Download PDF</button>

You would try with this instead

<a class="btn btn-primary btn-lg" href="http://anothersitehere.com/file.pdf">
   Download PDF
</a>

Leaving location.href blank and in javascript function give

document.location.href='page.php?variable='+value;

it will redirect to the page you want.

It's seems that it is working regarding on going to the link. I'm using Chrome btw.

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