コードは、外部で定義されているjavascript関数を呼び出す必要があります。例:
Javascriptファイル:
var formWin,
formWinParams = {
btnSelector: '.btn-on-form-win',
name: 'windowNameHere',
src: 'save.html',
// Advanced string join (param could just be one long string instead)
params: [
'width=600',
'height=400',
'left=0',
'top=0',
'toolbar=No',
'location=No',
'scrollbars=No',
'status=No',
'resizable=No',
'fullscreen=No'
].join(',')
},
swfFile;
/**
* Gets a javascript object reference to a swf file
* @return object
* @note You should swfobject or jquery to get your swf file but
* you might also need to setup a mechanism to make sure swf file
* is ready for interaction (or swf load is complete)
* @see example of load check http://abi.edu/js/new-video-gallery.js
*/
function getSwf (movieName) {
if ( navigator.appName.indexOf( "Microsoft" ) != -1 ){
return window[ movieName ];
}
else {
return document[ movieName ];
}
}
function onBtnClick (e) {
swfFile.functionFromSwfFileHere();
}
/**
* Gets form window lazily (if not there create it)
* @return window object
* @note Javascript function params are optional so we use the || operator to check if
* params are set otherwise we use our own values.
*/
function getFormWindow (src, name, params) {
src = src || formWinParams.src;
name = name || formWinParams.name;
params = params || formWinParams.params;
// Create window if not already created
if (formWin === null) {
formWin = window.open(src, name, params);
// Setup handling of the form window button click
$(formWinParams.btnSelector, formWin).click(onBtnClick);
}
// Bring window to front
formWin.focus();
return formWin;
}
// Wrap initialization of script for ease of use
function init () {
// Get reference to swf file
swfFile = getSwf('swfFileIdHere');
// Or use a library like jquery
swfFile = $('#swf-file-id-here');
}
// Initialize javascript on window load (using jquery)
$(function () {
init();
});
次に、UrlRequestソースを次のようなものに変更します
"javascript: getFormWindow();"
また
"javascript: getFormWindow('save.html', 'saveWin');"
そしてそれはすべてそこから処理され、actionscriptとjavascriptコードを簡素化し、より動的にします。