Javascript from flash script Accessing javascript from flash getUrl flash
Creating pop-up browser windows in flash
Flash can trigger a browser pop-up in many ways, this sample explains how to do this by JavaScript.We can use javascript in flash in very simple way.Just create a function in javascript and place that in header.In flash file you have only to use getUrl function for accessing that javascript function.
<!–adsencestart–>
Code to write in the flash file
Create a new flash file, create a simple button in it, click the button and type this code on the flash button:
on (release) {getURL(“javascript:openNewWindow(’http://www.macromedia.com’,'thewin’,‘height=400,width=400,toolbar=no,scrollbars=yes’)”);} Code to write in the html page:-
Now open the html page that contains the swf button and place this code between <head>…</head> area of the html code:
<script language=“JavaScript”>function openNewWindow(URLtoOpen, windowName, windowFeatures) {newWindow=window.open(URLtoOpen, windowName, windowFeatures); }</script>
Now you are done. When the flash button is clicked then the flash button will trigger the JavaScript from the html page.
Options
You can adjust the first code (the on on the flash button) in order to adjust pop-up window options as follows: url to open, window name, height, width, toolbars (yes/no) and scroll bars (yes/no).
or also you have another like choice:-Code to go in html page top
<script language=”javascript”>
function redirect_now()
{
window.location=”yahoo.com”;
}
</script>
Now code for flash button:-
on (release) {
getURL(”javascript:redirect_now()”);
}


Discussion Area - Leave a Comment
You must be logged in to post a comment.