初学者的 JavaScript 问题
美好的一天,我一直在谷歌上搜索我遇到的很多问题,我总是在这里找到答案,我希望有人能花时间回答这个愚蠢的问题。我是 JavaScript 的初学者,我碰巧正在创建一个个人网站,该网站使用 Flexpaper 作为我的一些文件的查看器,我只是想知道如何根据用户将单击的 href 更改 URL 。以下是 Flexpaper 片段:
var swfVersionStr = "10.0.0";
var xiSwfUrlStr = "playerProductInstall.swf";
var file = "1984.swf";
var flashvars = {
SwfFile : escape(file),
Parameters here
};
var params = {
}
Parameters and Attributes here
swfobject.embedSWF(
"FlexPaperViewer.swf", "flashContent",
"700", "550",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display:block;text-align:left;");`
我计划将查看器放在 iframe 上或仅放在一侧,然后将链接放在另一侧或框架上。
<a href="books/google search APIs.swf">Google search APIs</a>
它应该更改代码上的变量文件。我希望你能帮助我。
Good day, I've been searching Google on a lot of issues I have and I always find the answers here and I'm hoping that someone would give time answering this stupid question. I'm a beginner in JavaScript and I happened to be creating a personal site that uses Flexpaper as the viewer for some of my files, and I'm just wondrin' how I can change the URL based on href that the users will click on. Here's the Flexpaper snippet:
var swfVersionStr = "10.0.0";
var xiSwfUrlStr = "playerProductInstall.swf";
var file = "1984.swf";
var flashvars = {
SwfFile : escape(file),
Parameters here
};
var params = {
}
Parameters and Attributes here
swfobject.embedSWF(
"FlexPaperViewer.swf", "flashContent",
"700", "550",
swfVersionStr, xiSwfUrlStr,
flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display:block;text-align:left;");`
I'm planning to put the viewer on iframe or just on the side, and then the links on the other side or frame.
<a href="books/google search APIs.swf">Google search APIs</a>
It should change the variable file on the code. I'm hoping you could help me out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试定义以下 javascript 函数(名为
swapSwf
):只需在带有正确
javascript:
前缀的链接中使用它即可:Try defining the following javascript function (which named
swapSwf
):And the just use it in the link with the proper
javascript:
prefix:首先,使用函数创建 SWF,这样您就可以为不同的文件传递单独的参数。
其次,在锚标记中,在函数末尾返回 false,同时在锚标记内的 onClick 事件处理程序中也使用“return false”。这将取消浏览器中的链接,并允许该功能执行其任务(更改 FlexPaper 文档)。
(我没有检查以下内容,因此您必须进行测试)
然后,将带有 swfFile 位置的 showFile 函数作为参数传入:
First, use a function to create the SWF, that way you can pass in separate parameters for different files.
Second, in the anchor tag, return false at the end of your function, while also "return false" is used in the onClick event handler within the anchor tag. This will cancel following the link within the browser, and allow the function to do it's business (changing the FlexPaper document).
(I haven't checked the following, so you will have to test)
Then, the showFile function with the location of the swfFile is passed in as a parameter: