在jQuery创建的DIV中运行带有“document.write”调用的javascript。如何?

在jQuery创建的DIV中运行带有“document.write”调用的javascript。如何?,javascript,jquery-plugins,modal-dialog,popupwindow,Javascript,Jquery Plugins,Modal Dialog,Popupwindow,我试图让一个基于javascript的世界时钟在一个弹出div中运行,该div用jQuery显示。 当我在Dreamweaver Live View中查看它时,它工作得非常好。但是当我把它上传到我的服务器,Javascript showclockobj,它包含一个文档。。。命令,立即执行并用映射重写整个屏幕。因此,我从worldclock.html javascript中调用了showclockObj,并将其放入打开div的jQuery处理程序中。但它不在div中,它占据了整个屏幕 如何让它像页

我试图让一个基于javascript的世界时钟在一个弹出div中运行,该div用jQuery显示。 当我在Dreamweaver Live View中查看它时,它工作得非常好。但是当我把它上传到我的服务器,Javascript showclockobj,它包含一个文档。。。命令,立即执行并用映射重写整个屏幕。因此,我从worldclock.html javascript中调用了showclockObj,并将其放入打开div的jQuery处理程序中。但它不在div中,它占据了整个屏幕

如何让它像页面上所有其他按钮一样显示在div中?提示、转换、添加、编辑、复制等

这是链接,如果你想看看我在做什么:

以下是JS:

<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——您有几个不同的版本 这可能是导致此错误的原因:

$picker.farbtastic不是函数 源文件: 第26行

要处理document.write,请重写它

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.htmlstringToWrite

但是看看JS,你也可以替换它

function showBanner(BannerLink){
    document.write(BannerLink);
}

更新:将整个外部脚本替换为

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'.htmlshowclockobj.dialog…..

再次感谢。你搞定了。多亏了你的建议,我现在可以开始跑步了!
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;
}