|
主题: JS脚本的问题,打开自适应图片大小的窗口。
|
 jesron
职务:普通成员
等级:2
金币:1.0
发贴:393
注册:2001/1/27 0:06:31
|
#12004/3/31 15:53:38
下面这段是原始代码:
<script> window.open('javascript:document.write("<body style=margin:0><img src=http://127.0.0.1/pic.gif>");window.resizeTo(document.images(0).width,document.images(0).height+20)',"win1","toolbar=0") </script>
我想改成能够传递参数的JS脚本,就是打开的图片不固定,由网页调用传递过来,应该怎么改?
|
 =ridincal=
职务:管理员
等级:7
金币:20.0
发贴:5886
注册:2004/1/13 11:47:04
|
#22004/3/31 15:57:55
你说的网页调用传递过来是什么意思?后台设定? 只要修改img的src属性就可以了
|
 jesron
职务:普通成员
等级:2
金币:1.0
发贴:393
注册:2001/1/27 0:06:31
|
#32004/4/1 16:00:34
改成这样子对吗?我测试了一下,没有什么错误提示信息,也没办法弹出新窗口呀。 <script> function open_pic(Pic_Url) { window.open('javascript:document.write("<body style=margin:0><img src="+Pic_Url+">");window.resizeTo(document.images(0).width,document.images(0).height+20)',"win1","toolbar=0") } </script> 版主帮忙看看。
|
 =ridincal=
职务:管理员
等级:7
金币:20.0
发贴:5886
注册:2004/1/13 11:47:04
|
#42004/4/1 16:15:58
<script> function open_pic(Pic_Url) { window.open("about:<body style=margin:0><img src='"+Pic_Url+"'><script>window.resizeTo(document.images(0).width,document.images(0).height+20)<\/script><\/body>","win1","toolbar=0"); } </script>
|
 jesron
职务:普通成员
等级:2
金币:1.0
发贴:393
注册:2001/1/27 0:06:31
|
#52004/4/2 11:07:09
不行呀。版主改后的代码运行结果如下: 不行呀,版主给的代码运行后的结果: 取消操作 Internet Explorer 不能链接到您请求的网页。此页可能暂时不可用。 -------------------------------------------------------------------------------- 请尝试以下操作: 单击刷新按钮,或以后再试。 如果您以前查看过该页,现在要查看计算机上存储的内容,请单击文件,然后单击脱机工作。 要获得有关使用 Internet Explorer 脱机浏览的信息,请单击帮助菜单,然后单击目录和索引。 Internet Explorer 查看属性结果是: res://shdoclc.dll/navcancl.htm 去掉about:后运行的结果如下: 无法找到网页 您正在搜索的网页可能已经删除、更名或暂时不可用。 -------------------------------------------------------------------------------- 请尝试下列操作: 如果您在“地址”栏中键入了网页地址,请检查其拼写是否正确。 打开 localhost 主页,寻找指向所需信息的链接。 单击后退按钮尝试其他链接。 HTTP 404 - 无法找到文件 Internet 信息服务 -------------------------------------------------------------------------------- 技术信息(支持个人) 详细信息: Microsoft 支持 查看属性为: localhost/2004/admin/Product/<body%20style=margin:0><img%20src='UploadFiles/200442105510.jpg'><script>window.resizeTo(document.images(0).width,document.images(0).height+20)</script></body>
|
 =ridincal=
职务:管理员
等级:7
金币:20.0
发贴:5886
注册:2004/1/13 11:47:04
|
#62004/4/2 14:55:13
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
|