JavaScript function to travel to a WEB Page : redirect()

In flex we use navigateToUrl () method to traverse to a WEB page, usually with a link Button or Button.

So how to do this with Javascript code behind the flex App, the solution is simple with a line a code.

The line is :

window.location.href=”";

specify the link in the double quotes.

Example:

In flex iam having Button which calls the function redirect() at JS,which contains the line of code, then definition would be as below..,

Code at Flex app:

<mx:Button id=”btn” click=”b()”/>

<script>

private function b():void

{

ExternalInterface.call(“redirect”);

}

</script>

Code at JS/html wrapper:

<script language=”javascript”>

function redirect()

{

 window.location.href=”http://www.google.com/”

}

</script>

Now on click Button the page will travel to the Google Page.

5 Responses to “JavaScript function to travel to a WEB Page : redirect()”

  1. Traverse to previous page using JavaScript function. « flex on blog - by kumar Says:

    [...] function in the JS and call that function from Flex APP using the ExternalInterface method call(), [previous post describes this call] with a button, the the JS function is raised and the Page is [...]

  2. Shankar Says:

    Hi i used this above javascript coding for page navigation using button. But iam getting error in window property is not known.

    How to solve this one, its a separate js file to be included int mx:script or how to do this?

    Tell me..

  3. kumargandhi Says:

    Hi
    the code

    function redirect()

    {

    window.location.href=”http://www.google.com/”

    }

    should be in the html page of your Application, For Example i have a Application like FristFlexApplication in Flex Builder then the FlexBuilder Creates a Html page with the same name check it inthe bin-debug folder of your Project if using Flex Builder.

    If this is not clear to you , paste the code your using i will guide you from that.

    regards,
    kumar.

  4. travel vacation Says:

    well this is useful… (at least for me)

    very thanks

    ——————————–
    travel vacation

  5. kaushik Says:

    it is so much usefull for me

Leave a Reply