我有这个代码jQuery:(文件名是javascript.js ...之前我使用的是JavaScript ...)
$(document).ready(function() {
$("#readFile").click(function() {
$.get('test.txt', function(data) {
$("#bottom_pane_options").html(data); // #bottom_pane_options is the div I want the data to go
}, 'text');
});
});
Run Code Online (Sandbox Code Playgroud)
...这在HTML中:
<!DOCTYPE html>
<html>
<head>
<title>Culminating</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./javascript.js"></script>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCJnj2nWoM86eU8Bq2G4lSNz3udIkZT4YY&sensor=false">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(50.569283,-84.378433),
zoom:5,
mapTypeId:google.maps.MapTypeId.TERRAIN
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div class="content">
<div id="googleMap"></div>
<div id="right_pane_results">hi</div>
<div id="bottom_pane_options">
<button id="readFile">Read File</button> …Run Code Online (Sandbox Code Playgroud) 对于学校达到高潮,我获得了数据,可以使用并创建可视化.我开始在Netbeans中创建一个Java项目来读取文件并从数据中创建对象.现在,我决定使用需要JavaScript的Google Maps API来显示数据,我希望避免使用JavaScript重新编码所有内容.那么...有没有办法让我的网页(在JavaScript中)运行我的Java程序(它会给我对象)并返回一个充满这些对象的数组?此外,如果它改变了什么,我想在没有服务器的情况下从我的计算机目录运行网页.
谢谢,乔希
我有一个document.write()用于写入页面的JavaScript函数.我的问题是,当我单击按钮调用该函数时,document.write()将我已经拥有的内容替换为我正在编写的内容.有没有办法从JavaScript写一个特定的div文本?
这是我的HTML代码:
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="javascript.js">
</script>
<script>
// Calling the Google Maps API
</script>
<script>
<!-- JavaScript to load Google Maps -->
</script>
</head>
<body>
<div class="content">
<div id="googleMap"></div>
<div id="right_pane_results">hi</div>this -->
<div id="bottom_pane_options">
<button onclick="todaydate();">Try It</button>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
...和我的JavaScript代码(我从互联网上获得的东西只是为了测试):
function todaydate() {
var today_date = new Date();
var myyear = today_date.getYear();
var mymonth = today_date.getMonth() + 1;
var mytoday = today_date.getDate();
document.write("<h1>" + myyear + "/" + mymonth …Run Code Online (Sandbox Code Playgroud)