2つのdivで構成されるhtmlページがあります(左側のパネルと右側のパネル)。左のdivにはバックエンドの値がロードされます。左側のdivの値を選択すると、右側のdivにhtmlページをロードし、読み込まれているページのURLでパラメータを渡したいとします。私はjQueryを使用して、HTMLページで適切なdivをロードしています。また、URLにパラメータを渡しています( "#.editor")load( "editor.html?method =" + m)))。jQueryサーバー側の対話とwindow.locationなしでhtmlページ間のパラメータにアクセスする
私の質問は、他のhtmlページの値「メソッド」にどうやってアクセスするのですか?私は無駄に値にアクセスするwindow.location.hrefを使用してみました。親切に助けてください。私は以下のコードを貼り付けました。
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" href="./methodeditor.css" rel="stylesheet" />
<link type="text/css" href="../../css/ui-lightness/jquery-ui-1.8.14.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="../../js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="../../js/jquery-ui-1.8.14.custom.min.js"></script>
<title>Method editor</title>
<script>
function gethtml(m){
$(".editor").load('editor.html?method='+m);
}
function save(){
var editor = document.getElementById("editor");
var win = editor.contentWindow;
var form = win.document.getElementById("editor");
form.submit();
}
function getmethods() {
$.get ("listmethods.php" , function(data) {
var methods = JSON.parse(data);
for (var i=0; i< methods.length; i++){
$(".list").append("<div id=" + methods[i] + " class= clickable ><tr><td>" + methods[i] + "</td></tr></div>");
}
});
}
$('.clickable').live('click', function() {
var m = this.id;
gethtml(m);
});
</script>
</head>
<body>
<div class="methodeditor">
<div class="list">
<script>
getmethods();
</script>
</div>
<div class="editor" >
<script>
gethtml('default.xml');
</script>
</div>
<div class="buttons">
<input type="button" value="save" onclick="save()" />
</div>
</div>
</body>
</html>