这是我的代码在firefox中运行良好,但它不在chrome中。当我调试页面时,文本区域被创建但它不在chromes屏幕中。当我使用较低版本的jquery并且建议我开始使用此版本时,我收到了webkit错误。它解决了错误消息,但它无法解决实际问题。
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script type="text/javascript">
function loadAddressXML(address) {
var file = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + address + "&sensor=true";
if(window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
xml2 = xmlhttp.responseText;
alert(xml);
}
}
xmlhttp.open("GET", file, false);
xmlhttp.send();
}
$(document).ready(function(){
$("#searchButton").click(function(){
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv');
newTextBoxDiv.html('<label>Enter Address: </label> ');
newTextBoxDiv.html('<input type = "text" id="searchBar" size="35" value="dfsfsdfsfsf"/>');
newTextBoxDiv.appendTo("body");
$("#searchButton").remove();
});
});
</script>
</head>
<body>
<input id="searchButton" type="button" value="Search Address"/>
</body>