当点击超链接时,Msgbox警告(function())
Msgbox alert( function() ) when click on hyperlink
我想在点击一个单词时显示一个提示框,例如:
$d = "Hello how r u";
echo "<a onclick='"return alert('$d');'">helloo</a>";
它显示你好,然后当你点击它的消息框弹出"你好,你好吗"。Ps:对不起,我没有足够的信誉来显示img。
不只是显示一个变量,我可以显示一个函数()吗?
<!DOCTYPE html>
<html>
<body>
<?php
echo'
<script>
var zzz=undefined;
function lol()
{
<tablestyle="width:100%">
<tr style="background-color:#FFD700;">
<strong>
<th width="5%">EqID </th>
<th width="5%">Status</th>
<th width="5%">Proc Lot </th>
<th width="5%">Moves </th>
<th width="5%">Avl </th>
<th width="5%">Util </th>
</strong>
</tr>
</table>
}
zzz=lol();
</script>
';
echo "<a style='cursor:pointer'; onclick='"return alert(zzz);'">helloo</a>";
?>
</body>
</html>
这是我的代码。lol()实际上是我的表头的一个样本。我希望程序输出与上面例子中相同的东西,但是msgbox显示我的lol()。
你不能把HTML代码放在JS函数中。所以下面的代码是不正确的(你不能混淆JS代码和HTML代码)
function lol()
{
<tablestyle="width:100%">
<tr style="background-color:#FFD700;">
<strong>
<th width="5%">EqID </th>
<th width="5%">Status</th>
<th width="5%">Proc Lot </th>
<th width="5%">Moves </th>
<th width="5%">Avl </th>
<th width="5%">Util </th>
</strong>
</tr>
</table>
}
所以这个函数是无效的(语法错误)。
我认为你必须在继续之前修复这个bug。否则,JS解释器上的行为将是不可预测的。
类似的代码是:
<script>
function lol() {
return 1;
}
var zzz = lol(); //// zzz = 1;
<script>
<a style='cursor:pointer'; onclick="alert(zzz);">helloo</a> //// display message box 1
相关文章:
- chrome扩展更改主机/域警告
- 直接在函数声明上使用function.prototype.bind
- jQuery:.click(function(){(element),collapse('show',f
- 如何永久停止jshint'只读'警告/错误
- 如果连接类型为none,则Javascript Function Only警报
- JShint-.jshintrc中的ES6有esversion,但仍收到警告(使用atom)
- onLoad function phonegap android
- Webpack UglifyJS仍在发出警告消息
- reducers在redux中得到Function not Object,what'it’他错了
- 我确实有一个表单,如果用户输入了输入,它应该检查否定或空的输入框,并抛出一条警告消息
- WIll window.addEventListener(“加载”,function(),false);等待浏览器自动填
- $(document).ready和jQuery(function($)不工作;jQuery已定义,但脚本尚未定义;t进
- React Router一直给我一个警告:你不能更改<路由器路由>
- 为什么Grunt Copy给了我一个'undefined不是函数'警告
- 执行此代码时,我看不到警告框
- 页面中的声学警告
- 警告:file_get_contents(http://..@2x.png)[function.file-get-con
- 警告:session_start() [function.session-start]:不能发送会话缓存限制器
- 警告:session_start() [function.session-start]:不能发送会话缓存限制头已经发送
- 当点击超链接时,Msgbox警告(function())