我有一个HTML
文件,里面有一些Script
。
我将所有functions
放在一个Script
标记中。
现在我想在onload
和onclick
事件中使用这些方法。
这是包含所有脚本的HTML文件:
<!DOCTYPE html>
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js">
</script>
<script src="../configwireless.php">
</script>
<title>configuration</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.center {
margin: auto;
width: 40%;
border: 3px solid #73AD21;
padding: 10px;
text-align: center;
margin-left: auto;
margin-right: auto;
background : url(wall5.jpg) center no-repeat;
}
@font-face {
font-family: myFont;
src: url(fonts/Raleway-Medium.otf);
src: url(fonts/Raleway-Medium.ttf);
src: url(fonts/Raleway-Medium.woff);
}
body {
font-family:myFont;
background : url(wall5.jpg) center;
height: 100%;
font-family:myFont;
background-position: center;
background-repeat: repeat;
background-size: cover;
width: 100%;
}
lable {
font-family:myFont;
}
form{
font-family: myFont;
}
input {
text-align: center;
}
</style>
</head>
<body>
<form name="general" action="" id="general" class="center" method="post">
<div id="wirelessmodediv">
<label>Wireless Mode</label>
<select name="wirelessmode" id="wirelessmode"
onclick="checkGeneralWirelessMode()">
<option value="ap">AP</option>
<option value="xxx">Client</option>
<option value="xxx">Client Bridge(Routed)</option>
<option value="xxx">Adhoc</option>
<option value="xxx">WDS Station</option>
<option value="xxx">WDS AP</option>
</select> <br>
</div>
<div id="networkmodediv">
<label>Wireless Network Mode</label>
<select name="wirelessNetworkMode" id="wirelessNetworkMode">
<option value="disabled">Disable</option>
<option value="mixed">Mixed</option>
<option value="a-only">A-Only</option>
<option value="na-only">NA-Mixed</option>
<option value="n5-only">N-Only(5 GHz)</option>
</select> <br>
</div>
<div id="channelwidthdiv" >
<label> Channel Width </label>
<select id="channelWidth" name="channelWidth">
<option value="20">Full</option>
<option value="40">Wide </option>
<option value="2040">Dynamic </option>
<option value="10">Half (10 MHz)</option>
<option value="5">Quarter(5 MHz)</option>
</select> <br>
</div>
<div id="countrydiv">
<label>Country</label>
<select id="country" name="country"
onchange="fillWirelessChannel();"
onload="fillWirelessChannel();"
onclick="fillWirelessChannel();">
<option value="china" >China</option>
<option value="japan" >japan</option>
</select>
</div>
<br>
<div id="wirelesschannel">
<label>Wireless Channel</label>
<select id="wirelessChannel" name="wirelessChannel">
</select>
</div>
<br>
<div id="extentionchanneldiv">
<label> Extention Channel </label>
<select id="extentionChannel" name="extentionChannel">
<option value="auto">auto</option>
<option value="lower">lower</option>
<option value="upper">upper</option>
</select>
</div>
<br>
<div id="linkname" >
<label>Wireless Link Name</label>
<input type="text" name="ssid" id="ssid" /><br>
</div>
<div id="ssidbroadcast" >
<label>Wireless SSID Broadcast</label>
<input type="radio" name="broadcaststatus" id="enablebroadcaststatus"
value="0"> Enable
<input type="radio" name="broadcaststatus" id="disablebroadcaststatus" value="1" > Disable <br>
</div>
<div id="gatewaydiv" >
<label>Default GW Mode</label>
<input type="radio" name="gateway" id="gateway" value="1" onclick="checkDefaultGateway()"> Auto (DHCP)
<input type="radio" name="gateway" id="gateway" value="0" onclick="checkDefaultGateway()"> Manual <br>
</div>
<div id="gatewayipdiv" >
<label>Gateway</label>
<input type="text" name="gatewayip" id="gatewayip" ><br>
</div>
<label>Advanced Setting</label>
<input type="checkbox" name="advancecheck" id="advancecheck"
onchange="advancecheckChanged()"
onload="advancecheckChanged()"/><br>
<div id="advanceddiv" style="display:none;">
<label>Super Channel</label>
<input type="radio" name="supperchannel" value="ebable"> Enable
<input type="radio" name="supperchannel" value="disable"> Disable <br>
<label>TX Power</label>
<input type="text" name="txpower" id="txpower"><br>
<label>Antenna Gain</label>
<input type="text" name="antennagain" id="antennagain"><br>
<label>Noise Immunity</label>
<input type="radio" name="noise" id="enablenoise" value="1"> Enable
<input type="radio" name="noise" id="disablenoise" value="0"> Disable <br>
<label> Protection Mode </label>
<select id="protection">
<option value="None">one</option>
<option value="CTS">CTS</option>
<option value="RTS/CTS">RTS/CTS</option>
</select> <br>
<label>RTS Threshold</label>
<input type="text" name="rts" id="rts"> <br>
<label>Short Preamble</label>
<input type="radio" name="preamble" id="enablepreamble" value="ebable"> Enable
<input type="radio" name="preamble" id="disablepreamble" value="disable"> Disable <br>
<label>Short GI</label>
<input type="radio" name="gi" id="enablegi" value="1"> Enable
<input type="radio" name="gi" id="disablegi" value="0"> Disable <br>
<label>TX Antenna Chains</label>
<select id="txantennachains">
<option value="1">1</option>
<option value="3">1+2</option>
</select><br>
<label>RX Antenna Chains</label>
<select id="rxantennachains">
<option value="1">1</option>
<option value="3">1+2</option>
</select><br>
<label>Beacon Interval</label>
<input type="text" name="interval" id="interval"><br>
<label>DTIM Interval</label>
<input type="text" name="dtiminterval" id="dtiminterval"><br>
<label>AP Isolation</label>
<input type="radio" name="isolation" id="enableisolation" value="1"> Enable
<input type="radio" name="isolation" id="disableisolation" value="0"> Disable <br>
<label>Sensitivity Range (ACK Timing)</label>
<input type="text" name="sensitiverange" id="sensitiverange"><br>
<label>Max Associated Clients</label>
<input type="text" name="maxassociate" id="maxassociate"><br>
<label>Network Configuration</label>
<input type="radio" name="configuration" id="enableconfiguration" value="0"
onload="checkBridgeMode()"
onclick="checkBridgeMode()"
onchange="checkBridgeMode()"> Unbridge
<input type="radio" name="configuration" id="disableconfiguration" value="1"
onload="checkBridgeMode()"
onclick="checkBridgeMode()"
onchange="checkBridgeMode()"> Bridge<br>
<div id="multicastdiv">
<label>Multicast forwarding</label>
<input type="radio" name="multicast" id="enablemulticast" value="1"> Enable
<input type="radio" name="multicast" id="disablemulticast" value="0"> Disable <br>
<label>Masquerade / NAT</label>
<input type="radio" name="masquerade" id="enablemasquerade" value="1"> Enable
<input type="radio" name="masquerade" id="disablemasquerade" value="0"> Disable <br>
<label>Net Isolation</label>
<input type="radio" name="netisolation" id="enablenetisolation" value="1"> Enable
<input type="radio" name="netisolation" id="disablenetisolation" value="0"> Disable <br>
<label>Forced DNS Redirection</label>
<input type="radio" name="forcedns" id="enableforcedns" value="1"
onload="Checkradiobutton()" onclick="Checkradiobutton()" > Enable
<input type="radio" name="forcedns" id="disableforcedns" value="0"
onload="Checkradiobutton()" onclick="Checkradiobutton()"> Disable <br>
<label>Optional DNS Target</label>
<input type="text" name="optionaldns" id="optionaldns"><br>
<label>IP Address</label>
<input type="text" name="ipaddress" id="ipaddress"><br>
</div>
</div>
<div id="subnetmaskdiv" style="display:none;">
<label>Subnet Mask</label>
<input type="text" name="subnetmask" id="subnetmask"><br>
</div>
<input type="submit" name="apply" id="apply" value="Apply"/>
</form>
<script type="text/javascript">
function checkGeneralWirelessMode() {
if ((document.getElementById('wirelessmode').value == "ap") ||
(document.getElementById('wirelessmode').value == "infra") ||
(document.getElementById('wirelessmode').value == "wdsap"))
{
document.getElementById("channelwidthdiv").style.display = 'block';
document.getElementById("countrydiv").style.display = 'block';
document.getElementById("extentionchanneldiv").style.display = 'block';
document.getElementById("wirelesschannel").style.display = 'block';
document.getElementById("linkname").style.display = 'block';
document.getElementById("ssidbroadcast").style.display = 'block';
document.getElementById("networkmodediv").style.display = 'block';
document.getElementById("gatewayipdiv").style.display = 'none';
document.getElementById("gatewaydiv").style.display = 'none';
} else if (document.getElementById('wirelessmode').value == "wet") {
document.getElementById("networkmodediv").style.display = 'block';
document.getElementById("gatewayipdiv").style.display = 'block';
document.getElementById("linkname").style.display = 'block';
document.getElementById("gatewaydiv").style.display = 'block';
document.getElementById("extentionchanneldiv").style.display = 'none';
document.getElementById("channelwidthdiv").style.display = 'none';
document.getElementById("countrydiv").style.display = 'none';
document.getElementById("wirelesschannel").style.display = 'none';
document.getElementById("ssidbroadcast").style.display = 'none';
} else if (document.getElementById('wirelessmode').value == "sta" ||
document.getElementById('wirelessmode').value == "wdssta") {
document.getElementById("channelwidthdiv").style.display = 'block';
document.getElementById("linkname").style.display = 'block';
document.getElementById("networkmodediv").style.display = 'block';
document.getElementById("extentionchanneldiv").style.display = 'none';
document.getElementById("gatewayipdiv").style.display = 'none';
document.getElementById("gatewaydiv").style.display = 'none';
document.getElementById("countrydiv").style.display = 'none';
document.getElementById("wirelesschannel").style.display = 'none';
document.getElementById("ssidbroadcast").style.display = 'none';
}
}
function advancecheckChanged() {
if (document.getElementById('advancecheck').checked &&
document.getElementById('enableforcedns').checked) {
document.getElementById("advanceddiv").style.display = 'block';
document.getElementById("subnetmaskdiv").style.display = 'block';
} else
document.getElementById("advanceddiv").style.display = 'none';
document.getElementById("subnetmaskdiv").style.display = 'none';
}
function fillWirelessChannel() {
var index;
var selectTag = document.getElementById('wirelessChannel');
selectTag.options.length = 0;
var auto = document.createElement("option");
auto.value = 'auto';
auto.innerHTML = 'auto';
selectTag.appendChild(auto);
// console.log(document.getElementById('country').value);
if (document.getElementById('country').value == "iran") {
for (index = 4920; index <= 5825; index += 5) {
var opt = document.createElement("option");
opt.value = index;
opt.innerHTML = index;
selectTag.appendChild(opt);
}
} else if (document.getElementById('country').value == "japan") {
for (index = 4920; index <= 6075; index += 5) {
var otherOpt = document.createElement("option");
otherOpt.value = index;
otherOpt.innerHTML = index;
selectTag.appendChild(otherOpt);
}
}
}
function checkDefaultGateway() {
if (document.getElementById('gateway').checked) {
document.getElementById("gatewayipdiv").style.display = 'none';
} else
document.getElementById("gatewayipdiv").style.display = 'block';
}
function checkBridgeMode() {
if (document.getElementById('enableconfiguration').checked) {
document.getElementById("multicastdiv").style.display = 'block';
} else
document.getElementById("multicastdiv").style.display = 'none';
}
function Checkradiobutton() {
if (document.getElementById('enableforcedns').checked) {
document.getElementById("subnetmaskdiv").style.display = 'block';
} else
document.getElementById("subnetmaskdiv").style.display = 'none';
}
</script>
</body>
</html>
我可以在onclick
事件中使用onclick
方法调用我想要使用特定方法的每个标记中的方法。
但我想尝试onload
中的所有方法。
我在标签中尝试了onload="functionName;"
,但没有效果。
我在脚本标记的末尾使用了window.onload="functionName";
,但没有效果。
我只能使用
window.onload=function somefuntion() {
在函数声明和工作中。
但只是对于一种方法,我可以这样做,当我这样做时,onclick
方法不起作用。
如何在onload
和onclick
中使用这些方法?在我满意的标签?
答案 0 :(得分:0)
也许只是:
window.addEventListener("load", function(event){
someFunc1();
someFunc2();
},false);