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 0
Add a ment  | 

3 Answers 3

Reset to default 5

What 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.";

本文标签: javascriptHow can I make a button redirect my page to another page using addEventListenerStack Overflow