nmduc073 posted on March 02, 2009 06:44

::758 view(s)
Ngữ cảnh ở đây là từ trang HTML/ascx, mình nhúng 1 file swf và có truyền tham số cho nó. Mình đã mất khá nhiều thời gian cho thằng này. T_T Nhưng cuối cùng cũng đã thành công. ^_^
Đầu tiên, mình xin trình bày cách gọi và truyền tham số tới file swf trên HTML trước đã. Thực sự mình đã search khá nhiều cho vụ truyền tham số này. Có nhiều cách được trình bày trên mạng nếu bạn search với từ khóa pass parameter to swf file in HTML. Bực 1 cái là chẳng có 1 full example code để nó chạy cả. Còn chạy các đoạn code mà nó đưa thì lại chẳng thấy chạy gì cả. Bực cả mình với nó. Cuối cùng, may mắn cũng đến với anh. Và đây là code của nó. Chỉ thêm 1 chút so với việc hiển thị swf file bình thường.
<!-- saved from url=(0014)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Photo Viewer</title>
<script src="AC_OETags.js" language="javascript"></script>
<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------
// -->
</script>
</head>
<body scroll="no">
<script language="JavaScript" type="text/javascript" src="history.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);
// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
// Check to see if a player with Flash Product Install is available and the version does not meet the requirements for playback
if ( hasProductInstall && !hasRequestedVersion ) {
// MMdoctitle is the stored document.title value used by the installation process to close the window that started the process
// This is necessary in order to close browser windows that are still utilizing the older version of the player after installation has completed
// DO NOT MODIFY THE FOLLOWING FOUR LINES
// Location visited after installation is complete if installation is required
var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
var MMdoctitle = document.title;
[Read the rest of this article...]