admin管理员组文章数量:1356304
Currently after searching the internet I've e up with this code:
function button(){
var button= getElementById("Sailthru");
button.addEventListener(MouseEvent.CLICK, onClick, false, 0, true)
function onClick(e:MouseEvent):void{
navigateToURL(new URLRequest("/"), "_blank");
};
Though it doesn't work, and I am unsure how to proceed. If there are no ways to make it work using this, then I will happily use another method. However I would like to use this method since I've been working on this for a while.
Currently after searching the internet I've e up with this code:
function button(){
var button= getElementById("Sailthru");
button.addEventListener(MouseEvent.CLICK, onClick, false, 0, true)
function onClick(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.sailthru./"), "_blank");
};
Though it doesn't work, and I am unsure how to proceed. If there are no ways to make it work using this, then I will happily use another method. However I would like to use this method since I've been working on this for a while.
Share Improve this question edited Jul 12, 2016 at 20:50 Dylan Wheeler 7,09414 gold badges57 silver badges81 bronze badges asked Jul 12, 2016 at 20:16 Darren BlairDarren Blair 211 gold badge1 silver badge3 bronze badges 03 Answers
Reset to default 5What language mix is this?
The easiest way to go about this using plain vanilla javascript is something like this:
var button = document.getElementById("Sailthru");
button.addEventListener("click", function(){
document.location.href = 'http://www.sailthru.';
});
Alternatively, this uses HTTP redirects.
HTML
<button id="btn">
Click
</button>
JS
btn.onclick = function() {
window.location.replace("http://www.sailthru./");
}
you can try
window.open or window.location based on your demand
window.open('http://test.','_blank');
window.location="http://test.";
版权声明:本文标题:javascript - How can I make a button redirect my page to another page using addEventListener? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743969015a2570418.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论