SWFObject 相对路径
无论我尝试什么,我都无法使这个 swf 文件工作。 如果我将所有文件放入我的根目录中,一切都会正常工作。
这是我的路径格式;
root:我的index.php 所在的位置。
在根目录中,我有一个名为“public”的文件夹。
在“public”内,我有另一个名为“_carousel_flash”的文件夹。 这是我的 swf 文件所在的位置。 我在这个目录中还有“js”文件夹。
这是我用于添加 swf 文件的 html 代码。
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Galleria - Inspire Creativity</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="public/_carousel_flash/js/swfobject.js"> </script>
<script type="text/javascript" src="public/_carousel_flash /js/swfaddress.uncompressed.js"></script>
</head>
<body>
<div id="contents">
</div>
<script type="text/javascript">
var so = new SWFObject("public/_carousel_flash/block_slider.swf", "movie", "100%", "100%", "8", "#ffffff");
so.addParam("quality", "high");
so.addParam("id", "movie");
so.addParam("allowFullscreen", "true");
so.write("contents");
so.addParam("salign", "t");
</script>
</body>
</html>
Whatever I try I couldn't make this swf file work.
if I put all the files into my root everything works perfectly fine.
Here is my path format;
root: where my index.php located.
inside the root, I have a folder called "public".
inside "public" I have another folder called "_carousel_flash".
This is the place where my swf file is located.
I also have "js" folder located in this directory.
Here is the html code I'm using for adding the swf file.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Galleria - Inspire Creativity</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="public/_carousel_flash/js/swfobject.js"> </script>
<script type="text/javascript" src="public/_carousel_flash /js/swfaddress.uncompressed.js"></script>
</head>
<body>
<div id="contents">
</div>
<script type="text/javascript">
var so = new SWFObject("public/_carousel_flash/block_slider.swf", "movie", "100%", "100%", "8", "#ffffff");
so.addParam("quality", "high");
so.addParam("id", "movie");
so.addParam("allowFullscreen", "true");
so.write("contents");
so.addParam("salign", "t");
</script>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
PUBLIC拼写错误
PUBLIC spell mistake
否则我猜
标记会导致一些问题,请尝试嵌入您的 swf 目标文件
Or else i guess
<script>
tag is causing some issues, try embedding your swf object file我无法确定是什么导致了您的错误,但我注意到您的代码有以下几点:
您使用的是 SWFObject 1.x,它非常过时,并且使用与 SWFObject 2.x 不同的语法。您是否有适用于 SWFObject 1.x 的正确 swfobject.js 文件?对于 SWFObject 用户来说,这是一个相当常见的问题。
在 SWFObject 1.x 中,您无法在
so.write
语句之后添加addParam
...它不会反映在您的页面中。应该是
SWFAddress 的 URL 中有一个拼写错误(“/js/”之前有一个空格)。
如果您想确保 SWF 位于根目录中,请尝试使用绝对 URL 直接在浏览器中加载它。
说到绝对 URL,在 SWFObject 代码中尝试它们通常也很有帮助。您当前的 URL 是文件相关的;我建议使用站点相对 URL (
"/foldername/filename.swf"
) 或绝对 URL ("http://yourdomain.com/foldername/filename.swf"< /代码>)。
I can't be sure what's causing your error, but here are some things I notice about your code:
You're using SWFObject 1.x, which is very outdated and uses different syntax than SWFObject 2.x. Do you have the correct swfobject.js file for SWFObject 1.x? This is a fairly common issue for SWFObject users.
In SWFObject 1.x, you can't
addParam
after theso.write
statement... it will not be reflected in your page.should be
You have a typo in the URL for SWFAddress (a space just before "/js/").
If you want to be sure your SWF is located in the root, try loading it directly in the browser using the absolute URL.
Speaking of absolute URLs, it's often helpful to try them in your SWFObject code, too. Your current URL is file-relative; I suggest either using a site-relative URL (
"/foldername/filename.swf"
) or an absolute URL ("http://yourdomain.com/foldername/filename.swf"
).