我的html体中有一个onLoad方法,它调用一个函数来根据我的url中的php变量加载某些数据。
public class TestApplet extends Applet {
...
private final static byte SIGN = (byte) 0x01;
...
private final static byte[] MESSAGE = new byte[] { 'M', 'e', 's', 's', 'a', 'g', 'e' };
final static short BAS = 0;
public void process(APDU apdu) {
if (this.selectingApplet())
return;
byte buffer[] = apdu.getBuffer();
...
switch (buffer[ISO7816.OFFSET_INS]) {
case SIGN:
try {
ECDSAKeyPair = Secp256k1Domain.getKeyPairParameter();
ECDSAKeyPair.genKeyPair();
ECDSAPublicKey = (ECPublicKey) ECDSAKeyPair.getPublic();
ECDSAPrivateKey = (ECPrivateKey) ECDSAKeyPair.getPrivate();
ECDSASignature = Signature.getInstance(Signature.ALG_ECDSA_SHA, false);
short signLen = 0;
byte[] signatureArray = new byte[70];
ECDSASignature.init(ECDSAPrivateKey, Signature.MODE_SIGN);
signLen = ECDSASignature.sign(MESSAGE, BAS, (short) MESSAGE.length, signatureArray, BAS);
apdu.setIncomingAndReceive();
Util.arrayCopyNonAtomic(signatureArray, (short) 0, buffer, (short) 0, (short) signatureArray.length);
apdu.setOutgoingAndSend((short) 0, (short) signatureArray.length);
} catch (CryptoException c) {
short reason = c.getReason();
ISOException.throwIt((short) ((short) (0x9C00) | reason));
}
break;
...
return;
}
}
这是我的onLoad调用:当我检查googles chrome inspect元素时,它在我运行页面时显示两个变量名称。
body onLoad="getData(<?php echo $_GET['Category']; ?>, <?php echo $_GET['Product']; ?>);"
我的功能是这个,但由于某种原因,如果我从上面传入参数onload它不起作用,但如果我使用没有变量的getData()它运行。我不明白为什么如果使用变量它没有运行.load。我没有在php中正确调用URL变量吗?
答案 0 :(得分:2)
我认为如果它们是字符串,你需要将变量包装在引号中:
body onLoad="getData('<?php echo $_GET['Category']; ?>', '<?php echo $_GET['Product']; ?>');"