加载jquery后,Opera停止加载我的页面

时间:2013-06-12 02:04:40

标签: javascript jquery opera window.open

我看了看,但我似乎找不到类似的情况。我正在使用javascript打开一个新窗口,然后从所述窗口发布信息。我的问题是我正在尝试加载jquery,然后加载一个脚本进行验证,我写完之后,但是在加载jquery之后,Opera似乎停止渲染任何东西。 我会发布我的代码,所以也许有人可以抓住我错过的东西。

a.document.open("text/html");
a.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />' +        '<link href="css/theme-simple.min.css" rel="stylesheet" type="text/css" />' +
    '<link href="css/animate.min.css" rel="stylesheet" type="text/css" />' +
    '<link rel="stylesheet" type="text/css" href="css/style.min.css" />' +
    '<link rel="stylesheet" type="text/css" href="css/body.min.css" />' +
    '<link rel="icon" type="image/png" href="img/favicon.ico"><style>li {font-size:10pt}</style></head><body><span style="display:none">');
var output = document.getElementById('productbox').innerHTML;
//output = output.replace((/\<IMG /,  "\<ignore"));
output = output.replace(new RegExp("<img ", "gi"), '<ignore');
// bodyText.replace(new RegExp("<font>", "gi"), '');
a.document.write(output.replace(/Total/, "Total per server").replace(/Email/, "").replace(/Print/, "").replace(/Qty:/, "").replace(/<img /, "<ignore"));
//a.document.write(output.replace(/Total/, "Total per server").replace(/Email/, "").replace(/Print/, "").replace(/Qty:/, "").replace(/<img src="\/images\/spinning_the_envelope.gif">/, "").replace(/<img src="\/images\/print30px.gif" width="20px">/, ""));

a.document.write('</span><form id="form2" name="form2" method="POST" action="success.php"><input type="hidden" name="formType" value="quote"><input type="hidden" name="fn" value="contact"><input type="hidden" Name="From" value="Quote from Orange Computers"><input type="hidden" name="Phone" value="314-921-9700"><input type="hidden" name="TollFree" value="877-921-9700"><input type="hidden" name="WebSite" value="www.orangecomputers.com"><br />' +
'<table class="topRow" style="width:500px;"><tr><td><div style="float:left;line-height:25px;">Email Address:</div> <div class="valignTop"><span id="anonemail" class="ei"><input type="text" id="HK" name="Email" size="40" style="height:18px;" /></span> <input id="submitAQuote" type="submit" class="btn valignTop" value="Send This Quote" name="button"></div><div style="clear:left;float:left;display:none;color:red;font-weight:bold;" id="Invalid"></td></tr><tr><td>Comments: optional<br /><textarea style="float:left;width:500px;" rows="5" name="Message" cols="60"></textarea></td></tr><tr><td><textarea rows="25" cols="60" name="Quote" style="float:left;width:500px;height:400px;margin:auto;margin-bottom:2px;cursor:default;" readonly>');
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month = curr_month + 1;
var curr_hour = d.getHours();
var curr_min = d.getMinutes();
var curr_sec = d.getSeconds();
var millis = d.getMilliseconds();
var random = Math.floor((Math.random() * 100) + 1);
var quoteNumber = String(curr_date) + String(curr_month) + String(curr_hour) + String(random * 3) + String(curr_min) + String(curr_sec) + String(millis);

a.document.write("Please Note: Prices are subject to change without notice. \n");
a.document.write("Quote number: " + quoteNumber + "\n");
a.document.write("Total Per Server: $");
var price = document.getElementById('product-pric').innerHTML;
a.document.write(price);
a.document.write('\n');
var product = document.getElementById('product-title').innerHTML;
a.document.write(product);
a.document.write('\n');
a.document.write('\n');
//var elems = document.forms.myform.elements;
var count = $("#output li" ).length;

for (var i = 0; i <= count; i++) {
    if (a.document.getElementById('pt' + [i]) !== null) {
        var component = document.getElementById('pt' + [i]).innerHTML;
        /*
                    a.document.write(component);
                    */
        component = component.replace(/&(lt|gt);/g, function (strMatch, p1) {
                return (p1 === "lt") ? "<" : ">";
            });
        var strTagStrippedText = component.replace(/<\/?[^>]+(>|$)/g, "");
        a.document.write(strTagStrippedText);
        a.document.write('\n');
        a.document.write('\n');
    }
    else {}
}
a.document.write("Shipping Not Included");
a.document.write('\n');
/*if (a.document.getElementById('Ground2') !== null) {
    var Ground = document.getElementById('Ground2').innerHTML;
    a.document.write(Ground);
    a.document.write('\n');
}
else {}

if (a.document.getElementById('Second Day Air2') !== null) {
    var SDA = document.getElementById('Second Day Air2').innerHTML;
    a.document.write(SDA);
    a.document.write('\n');
}
else {}

if (a.document.getElementById('Next Day Air2') !== null) {
    var NDA = document.getElementById('Next Day Air2').innerHTML;
    a.document.write(NDA);
}
else {} */


a.document.write('</textarea></tr></td>');
a.document.write("<input type='hidden' name='link' value='http://www.orangecomputers.com/node/index.php?command=getQuote&quoteNum=" + quoteNumber + "' />");
var j = 0;
// var elems = document.forms.myform.elements;

for (var i = 0; i <= count; i++) {

    if (a.document.getElementById('pt' + [i]) !== null) {
        var id = document.getElementById('put' + [i]).value;
        if (document.getElementById('putt' + [i]) !== null) {
            var elemDesc = document.getElementById('putt' + [i]).value;
        }
        if (document.getElementById('putt' + [i]) !== null) {
            var elemPrice = document.getElementById('pri' + [i]).value;
        }
        var name = document.getElementById('put' + [i]).name;
        if (name == 'hddId') {
            a.document.write("<input type='hidden' name='hdd" + j + "' value='" + id + "' />");

            var hdDesc = document.getElementById('hdName' + [i]).value;
            a.document.write("<input type='hidden' name='hddName" + j + "' value='" + hdDesc + "' />");

            var hddQty = document.getElementById('qt' + [i]).value;
            a.document.write("<input type='hidden' name='hddQty" + j + "' value='" + hddQty + "' />");

            var hddId = document.getElementById('hddId' + [i]).value;
            a.document.write("<input type='hidden' name='hdRef" + j + "' value='" + hddId + "' />");

            var hddPrice = document.getElementById('pri' + [i]).value;
            a.document.write("<input type='hidden' name='hddPrice" + j + "' value='" + hddPrice + "' />");
        }
        else if (name == 'cpu') {
            a.document.write("<input type='hidden' name='cpu" + j + "' value='" + id + "' />");
        }
        else {
            a.document.write("<input type='hidden' name='elem" + j + "' value='" + id + "' />");
            if (elemDesc !== undefined) {
                a.document.write("<input type='hidden' name='elemName" + j + "' value='" + elemDesc + "' />");
            }
            if (elemPrice !== undefined) {
                a.document.write("<input type='hidden' name='elemPrice" + j + "' value='" + elemPrice + "' />");
            }
        }


        a.document.write('\n');
        a.document.write('&#10;');
        j++;
    }
    else {}
}

var builder = a.document.getElementById('config').value;
var serverQty = a.document.getElementById('qty').value;
var curPrice = a.document.getElementById('product-pric').innerHTML;

a.document.write("<input type='hidden' name='curPrice' value='" + curPrice + "' />");
a.document.write("<input type='hidden' name='serverQty' value='" + serverQty + "' />");
a.document.write("<input type='hidden' name='builder' value='" + builder + "' />");
a.document.write("<input type='hidden' name='quoteNumber' value='" + quoteNumber + "' />");


a.document.write('<tr><td align="right"><input type="submit" class="btn" value="Send This Quote" name="button"></td></tr></table></form>');
a.document.write('<script type="text/javascript" src="scripts/jquery.js"></script>');
a.document.write('<script type="text/javascript" src="scripts/validator.js"></script>');
a.document.write('</body></html>');
//a.document.close();
if (navigator.appName !== "Microsoft Internet Explorer"){ a.document.close()};

Opera将所有内容加载到jquery,然后在它之后没有任何内容。我已经将脚本标记移动到几个不同的位置来测试它,它总是一样的。加载jquery后没有任何内容。 Opera不会抛出错误,我不明白发生了什么。任何帮助,将不胜感激!谢谢!

1 个答案:

答案 0 :(得分:0)

第1步:重写此内容。你不应该使用document.write,它是古代的遗迹,有两种非常简单的操作方式。

  1. DOM还在加载吗? document.write附加数据。
  2. DOM是否已完成加载? 所有document.write调用将您的文档重新保存到新的字符串数据
  3. 永远不要使用document.write。我不知道您的a变量是什么,但是您在其中添加了任何内容,您可以通过正确使用document.implementation.createDocumentdocument.createElement和标准{{1}来添加等等DOM函数

    第2步:获利。