论坛首页 Web前端技术论坛

受不了,这个问题困了我很久了。

浏览 5277 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2006-11-28  
很简单的一句话,就是在onclick事件中改变一个images对像的src。

但是,同样的一个页面上面,两个地方调用,一个地方调用这个images对像能正常显示,但另一个地方调用就不行,这个images对像就不显示图片了,而我点“显示图片”又能出来。

function popUp(src){

   tree.icons[0].src = src;
   ....

}

方法就这么简单,请哪位有经验的高手帮看下,倒底为什么,在这先谢谢了。
   发表时间:2006-11-28  
还有另一个问题,找了很多资料都没有解决,呵呵。

就是页面上的文件选择器(<input type="file">),怎么控制用户的选择类型,如:*.jpg,*.bmp等。

0 请登录后投票
   发表时间:2006-11-28  
设置正确否,虽然js没有好的debug工具,但是你自己可以利用起来嘛,比如alert document.write toString  for...in 等 个人意见 我也不知道问题在哪里哦
0 请登录后投票
   发表时间:2006-11-28  
yanbory 写道
还有另一个问题,找了很多资料都没有解决,呵呵。

就是页面上的文件选择器(<input type="file">),怎么控制用户的选择类型,如:*.jpg,*.bmp等。



提交前自己写js判断啊 弄个允许列表,不在里面的就不能提交不就OK了
0 请登录后投票
   发表时间:2006-11-28  
Maybe you should show your runing environment.
0 请登录后投票
   发表时间:2006-11-28  
yanbory 写道
还有另一个问题,找了很多资料都没有解决,呵呵。

就是页面上的文件选择器(<input type="file">),怎么控制用户的选择类型,如:*.jpg,*.bmp等。



You are not able to control shown file type on file dialog of IE. You can make an Applet or Activx plugin for that.

0 请登录后投票
   发表时间:2006-11-28  
jianfeng008cn 写道
yanbory 写道
还有另一个问题,找了很多资料都没有解决,呵呵。

就是页面上的文件选择器(<input type="file">),怎么控制用户的选择类型,如:*.jpg,*.bmp等。



提交前自己写js判断啊 弄个允许列表,不在里面的就不能提交不就OK了


我现在就是这样做的啊。

if(curValue.substring(curValue.lastIndexOf("."))==".jpg"){

return true;

}else{

alert("只能选择JPEG格式的文件(即文件名以.jpg结尾的文件)。");
curObj.focus();
return false;

}

就是觉得,随便一个GUI程序都可以完成的功能,在IE里面需要这样牵强,而且,如果类型多了,就麻烦了。。。呵呵。
0 请登录后投票
   发表时间:2006-11-28  
xiaoyu 写道
yanbory 写道
还有另一个问题,找了很多资料都没有解决,呵呵。

就是页面上的文件选择器(<input type="file">),怎么控制用户的选择类型,如:*.jpg,*.bmp等。



You are not able to control shown file type on file dialog of IE. You can make an Applet or Activx plugin for that.



谢谢,有相关的例子吗?
0 请登录后投票
   发表时间:2006-11-28  
jianfeng008cn 写道
设置正确否,虽然js没有好的debug工具,但是你自己可以利用起来嘛,比如alert document.write toString  for...in 等 个人意见 我也不知道问题在哪里哦


都用过了,而且,不止在一台机器上测试,就是用alert(),把这个images对像的src打印出来,路径什么都是对的,而且,同一个页面,同样的调用,也没有什么嵌套,但是就出不来。呵呵,因为这么一个小问题,我做的树,只能点“+”,“-”然展开和关闭节点,直接点节点上的文字就不行,而且从来没有遇到过这种问题。

也怀疑过是IE对JS的兼容问题,也怀疑过是OS的问题,但都换了N次了。问题依旧啊。呵呵。

为了让大家看清楚一些,我把这个方法发出来,大家看看。

// opens or closes a node locally
function ocLocal(treeName, nodePath, bottom)
{
    var id = treeName + delimeter + nodePath;
var theDiv  = document.getElementById('div' + id);
var theJoin = document.getElementById('join' + id);
var theIcon = document.getElementById('icon' + id);
var uId = null;
var tree = trees[treeName];

if(theDiv == null)
{
    uId = escapeQuotes(id);
    theDiv = document.getElementById('div' + uId);
if(theJoin == null) theJoin = document.getElementById('join' + uId);
if(theIcon == null) theIcon = document.getElementById('icon' + uId);
    }

if(theDiv == null)      // could be due to a double quote
{
    uId = replaceDoubleQuotes(uId);
theDiv = document.getElementById('div' + uId);
        if(theJoin == null) theJoin = document.getElementById('join' + uId);
if(theIcon == null) theIcon = document.getElementById('icon' + uId);
}

    // if theJoin.src contains plus.gif, it means that the node is asked to be expanded
// if theJoin.src contains minus.gif, it means that the node is asked to be collapsed
    if(theJoin.src.indexOf("plus.gif") != -1 || theJoin.src.indexOf('plusbottom.gif') != -1)
   tree.openNodes[nodePath] = "true";
else
   tree.openNodes[nodePath] = null;
    
    storeOpenNodesInCookie(treeName);

if (theJoin.src.indexOf('plus.gif') != -1 || theJoin.src.indexOf('plusbottom.gif') != -1) // node is to be opened
{
if (bottom==1) theJoin.src = tree.icons[3].src;
else theJoin.src = tree.icons[2].src;
theIcon.src = tree.getNode(tree.rootNode,nodePath).iconOpen;
theDiv.style.display = '';
} else
{
if (bottom==1) theJoin.src = tree.icons[1].src;
else theJoin.src = tree.icons[0].src;
theIcon.src = tree.getNode(tree.rootNode,nodePath).iconClosed;
theDiv.style.display = 'none';
}
}
0 请登录后投票
   发表时间:2006-11-28  
yanbory 写道
很简单的一句话,就是在onclick事件中改变一个images对像的src。

但是,同样的一个页面上面,两个地方调用,一个地方调用这个images对像能正常显示,但另一个地方调用就不行,这个images对像就不显示图片了,而我点“显示图片”又能出来。

function popUp(src){

   tree.icons[0].src = src;
   ....

}

方法就这么简单,请哪位有经验的高手帮看下,倒底为什么,在这先谢谢了。


改变src是显示不了img才是正常的. 正确的方法应该是先将图片都"显示"出来 然后用层荫蔽起来
js改变img的css属性中的z坐标将其显示出来.

如果用svg就可以直接改变src
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics