代碼
提交代碼
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JavaScript實(shí)現(xiàn)全排列</title>
<script type="text/JavaScript">
function combine() {//點(diǎn)擊按鈕向webworker線(xiàn)程發(fā)送請(qǐng)求
var worker = new Worker('http://wiki-code.oss-cn-beijing.aliyuncs.com/html5/js/worker.js');
worker.postMessage(document.getElementById("str").value);
worker.onmessage= function (event) {
document.getElementById("result").innerHTML = event.data ; //監(jiān)聽(tīng)JavaScript線(xiàn)程的結(jié)果
};
}
</script>
</head>
<body>
<input type="text" id="str" />
<button onclick="combine()">全排列</button>
結(jié)果是:<div id="result" style="width:500px;height:500px;word-break: break-all;"></div>
</body>
</html>
運(yùn)行結(jié)果