首先加载JQuery,然后显示HTML页面内容?

时间:2012-02-10 20:53:24

标签: javascript jquery html

我有一个移动网站,遗憾的是我不能直接访问HTML上的任何内容,所以我使用JQuery来设置它的宽度,高度等等,问题是该网站实际上有762px的宽度(这是一个PC的正常站点)我给了320px宽度(对于iPhone屏幕),一切运行良好但在页面加载时它来自页面中间以适应320px屏幕大小。我强烈相信我的宽度的JQuery代码(320px,虽然我也为其他一些元素指定了Jquery)在html页面中加载内容之后正在采取行动。

(我在Opera移动仿真器320x480上看到了这个问题)

因此,如果我能够首先加载JQuery,那么页面中的内容(HTML)可以解决问题。你们有什么建议吗?

我的脚本在下面给出..

$(document).ready(function() {
$('head').append('<meta name="viewport" content="initial-scale=1.0, width=device-width" />');
$("table.bgContent").removeAttr("width");
$("table.bgContent").attr("width","320");
$("table.cart-header").removeAttr("width");
$("table.cart-header").css("background","none");
$("table.cart-header").css("border","none");
$("table.cart-header td:first").html('<a href="home.aspx"><img src="images/userdir/logomobile.gif" width="320" height="79" border="0"/></a>');
$('head').append('<meta name="viewport" content="initial-scale=1.0, width=device-width" />');
$("table:eq(2) td.bgHeaderBarCart").html(" ");
$('table.cart-header td:nth-child(2)').css('display', 'none');
$('hr').css('width','300px');
$('td.FormTextCart').removeAttr("width");
$('.cart-header').css('height','0px');
$('.ContentAreaCart').css('padding','0px');
$('.SpanOrderCenter').css({padding : '0px',   textAlign : 'left', fontWeight : 'normal', fontSize : '12px', width : '300px'});
});

1 个答案:

答案 0 :(得分:1)

只需在<div>标记中加入包装<body>,例如:

<html>
<head>
</head>
<body>
    <div id="wrapper" style="display:none;">
    </div>
</body>
</html>

然后在js文件中准备好文档,添加:

$("#wrapper").show();
相关问题