img,空src对在IE中运行的php有影响吗?
我讨厌无法解释编译器行为的情况。所以请帮助我理解,怎么可能...
我有两个 php 文件 - index.php
和 admin.php
。在index.php
中,我进行注册,并进行验证码检查,如果它们正确,我将session
变量的值设置为somevalue,(首先它有另一个值)并将客户端重定向到CMS所在的admin.php
! 现在,问题是什么,我在 admin.php
中有一个模块,它有一个 img 元素,我在单击时生成该元素的 src(使用 jquery...),但首先它有src 空
因此,我丢失了会话变量的新值(它再次变成另一个值)。它只发生在 IE 中!
但是如果我为 src 属性设置任何值,它就可以正常工作!
工作正常
请帮助我理解这种行为
i hate situations, when i can't explain the behavior of compiler. So help me please to understand, how it possible...
i have two php files - index.php
, and admin.php
. in index.php
i make registration, and captcha checking, and if they are correct, i set the value of session
variable to somevalue,(at first it has anothervalue) and redirect client to admin.php
where the CMS is!
And now, what is the problem, i have a module in admin.php
which has an img element, src of which i generate when it clicked(using jquery...), but at first it has src empty
<img src="" />
and due to it, i lose the new value of session variable(it becomes anothervalue again). IT happens only in IE!!!
BUT if i set any value to src
attribute, it works fine!!!
<img src="some.jpg" /> works fine
help me please to understund such behavior
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
URI“”解析为当前 URI。因此,浏览器尝试将当前所在的页面作为图像加载(并且所有关联的 PHP 都会再次运行)。
不要设置具有空 src 属性的图像。
The URI "" resolves to the current URI. So the browser tries to load the page it is currently on as an image (and all the associated PHP is run again).
Don't set images with an empty src attribute.
如果src属性为空,IE会向当前页面所在的目录发出请求。由于这可能是由 index.php 处理的,因此这似乎是负责更改会话变量的脚本。
长话短说:不要使用空的 src 属性。
If the src attribute is empty, IE makes a request to the directory in which the current page is located. Since this is probably handled by index.php, it would seem that that's the script responsible for changing the session variable.
Long story short: don't use an emptry src attribute.