日期:2014-05-16  浏览次数:20368 次

php的网页中调用了一个javascript的弹出窗口
我在php的网页中调用了一个javascript的弹出窗口,为什么原来的网页也跟着跳转成弹出窗口的url了呢

这个是弹出窗口的function代码:
<script language="javascript" type="text/javascript">

var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){
LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
}
if(pos=="center"){
LeftPosition=(screen.width)?(screen.width-w)/2:100;
TopPosition=(screen.height)?(screen.height-h)/2:100;
}
else if((pos!="center" && pos!="random") || pos==null){
LeftPosition=0;TopPosition=20;
}

settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';

win=window.open(mypage,myname,settings);
}
// -->
</script>


这个是我调用这个function的代码:
  $url = "credibleSource/credibleSource.php?evid=$info[proposition_id]";
$onclick = "NewWindow(this.href,'mywin','500','400','yes','center');return true";
$onfocus = "this.blur()";

$callJS = "<a href = $url onclick = $onclick onfocus=$onfocus>";

------解决方案--------------------
$callJS = "<a href = $url onclick = $onclick onfocus=$onfocus>";

你href也添加了url肯定会跳转的了 将href的值改为 javascript:void(0);
------解决方案--------------------
NewWindow 函数 return false