我试图得到一个基于javascript的"世界时钟"内运行的弹出式div显示与jQuery。当我在Dreamweaver实时视图中看到它时,效果非常好。但是,当我将其上传到服务器时,Javascript showClock(clockobj)(其中包含一个document.write(…)命令)立即执行并使用地图重写整个屏幕。因此,我从worldclock.html javascript中取出showClock(clockobj)调用,并将其放在打开div的jQuery处理程序中。地图出现点击。但是它不在div中,它占据了整个屏幕。
如何让它显示在div内,就像页面上所有其他按钮一样?(技巧,转换,添加,编辑,复制等)
这是链接,如果你想看看我在做什么:
http://www.bizzocall.com/cp-ManagePhone.phpJS:
<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">
clockobj=new Object;clockobj.clockfile="world001-blue.swf";
clockobj.TimeZone="PST";
clockobj.width=480;
clockobj.height=250;
clockobj.wmode="transparent";
</script>
这是jQuery:
<script type="text/javascript">
$(function(){
// Dialog box
$('#worldclock').dialog({
autoOpen: false,
width: 540,
buttons: {
"Cancel": function() {
$(this).dialog("close");
}
}
});
// Dialog Link
$('#worldclockbtn').click(function(){
$('#worldclock').dialog('open');
showClock(clockobj);
return false;
});
});
</script>
HTML: <div id="worldclock" class="DialogBox">
<?php require_once('worldclock.html'); ?>
</div>
<div class="tiptxt" id="worldclockbtn" >WORLD CLOCK
<div class="arrowInCircle"></div>
</div>
首先去掉一个jquery——你有几个不同的版本
它们可能是导致此错误的原因:
$("#选择器")。Farbtastic不是一个函数
源文件:http://www.bizzocall.com/cp-ManagePhone.php
线:26日
处理文档。写,重写
var oldWrite = document.write;
var stringToWrite = ""; // this is polluting the window scope, but is for demo purposes ok
document.write=function(str) {
stringToWrite+=str
}
并使用$("#someDiv").html(stringToWrite)
但是看看JS,你也可以直接替换
function showBanner(BannerLink){
document.write(BannerLink);
}
function showBanner(BannerLink){
$("#someDiv").html(BannerLink);
}
update:将整个外部脚本替换为
function showClock(obj){
//Aded by Takeshi Sugimoto on 2008/05/01 for SSL
var str = '';
if(obj.ssl == '1'){
str = '<embed src="https://secure.clocklink.com/clocks/';
}
else{
str = '<embed src="http://www.clocklink.com/clocks/';
}
//--
str += obj.clockfile;
str += "?";
for( prop in obj ) {
if( 'clockfile' == prop
|| 'width' == prop
|| 'height' == prop
|| 'wmode' == prop
|| 'type' == prop
) continue;
//Added by takeshi on 2007/01/29 (to display mutibyte chars by using URL encoding)
if(prop == "Title" || prop == "Message"){
str += ( prop + "=" + obj[prop] + "&" );
}
else{
str += ( prop + "=" + _escape(obj[prop]) + "&" );
}
//--
}
str += '" ';
str += ' width="' + obj.width + '"';
str += ' height="' + obj.height + '"';
str += ' wmode="' + obj.wmode + '"';
str += ' type="application/x-shockwave-flash">';
return str ;
}
function _escape(str){
str = str.replace(/ /g, '+');
str = str.replace(/%/g, '%25');
str = str.replace(/?/, '%3F');
str = str.replace(/&/, '%26');
return str;
}
和
$ (' # worldclock ') . html (showClock (clockobj)) .dialog…