简体   繁体   English

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

[英]Opera stops loading my page after jquery is loaded

I've looked and looked, but I cannot seem to find a similar situation to mine. 我看了看,但是我似乎找不到与我类似的情况。 I'm using javascript to open a new window and then post information from said window. 我正在使用javascript打开一个新窗口,然后从该窗口发布信息。 My problem is that I am trying to load jquery and then load a script for validation that I wrote after it, but Opera seems to stop rendering anything after jquery is loaded. 我的问题是我尝试加载jquery,然后加载我在它之后编写的用于验证的脚本,但是Opera似乎在加载jquery之后停止呈现任何内容。 I will post my code, so maybe someone can catch what I missed. 我将发布我的代码,以便也许有人可以捕捉到我错过的内容。

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 loads everything up until jquery and then nothing after it. Opera将所有内容加载到jquery,然后再加载。 I've moved the script tag to several different locations to test it, and it's always the same. 我已经将脚本标签移到几个不同的位置进行测试,并且始终相同。 Nothing after jquery is loaded. 加载jQuery之后什么也没有。 Opera doesn't throw an error, and I don't understand what is happening. Opera不会抛出错误,我也不知道发生了什么。 Any help would be appreciated! 任何帮助,将不胜感激! Thank you! 谢谢!

step 1: rewrite this. 步骤1:将其重写。 You're not supposed to use document.write , it's a remnant of ancient times and has two very simple modes of operation. 您不应该使用document.write ,它是古老的遗迹,并且具有两种非常简单的操作模式。

  1. Is DOM still loading? DOM是否仍在加载? document.write appends data. document.write追加数据。
  2. Is DOM done loading? DOM完成加载了吗? ALL document.write CALLS RESET YOUR DOCUMENT TO THE NEW STRING DATA 所有document.write调用将您的文档重置为新的STRING数据

Never, ever, use document.write . 永远不要使用document.write I have no idea what your a variable is, but anything you're adding in there, you can add in there by properly using document.implementation.createDocument , document.createElement , and the standard appendChild , etc. DOM functions 我不知道您a变量是什么,但是您要在其中添加任何内容,都可以通过正确使用document.implementation.createDocumentdocument.createElement和标准appendChild等在其中添加appendChild函数

step 2: profit. 步骤2:获利。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM