我是 html5 & js 的新手,我在开发jQuery Mobile 示例时遇到了一些麻烦。
From this, i'm just calling another header (partial) when a product is selected to render.
_header2.php:
<!DOCTYPE html>
<head>
<title>h2: <?php echo $_GET['product']; ?> </title>
<meta charset="UTF-8" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;' name='viewport' />
<link rel='stylesheet' href='assets/css/styles_mob.css'/>
<link rel='stylesheet' href='assets/css/styles.css' />
<link href='assets/css/jquery-mobile.css?<?php echo filemtime("assets/css/jquery-mobile.css");?>' type='text/css' rel='stylesheet' />
<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.min.js'></script>
<script type='text/javascript' src='http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js'></script>
</script>
<script type='text/javascript'>
function mymessage(msg)
{
if(!msg) msg="?";
alert(msg);
}
</script>
</head>
<body onload="mymessage('onload !')">
<div data-role="page" id="Home">
<div data-role="header" data-theme="b">
<a href="./" data-icon="home" data-iconpos="notext" data-transition="fade">Home</a>
<h1> <?php echo $title?></h1>
</div>
<div data-role="content">
标题代码在生成的页面上正确显示,但在 body 标记中调用mymessage()的 js不起作用。当我尝试从另一个部分代码(_product.php)调用它时,同样的问题:
<li><a href='#Gallery1' onClick='mymessage(\"press gallery\")' >...</li>
...concole 返回:referenceError:mymessage 未定义
一切都只有在刷新当前页面时才会摇滚!!
我骑过一些有类似问题的帖子(1、2、3 ),但我还是迷路了。
请问有什么想法吗?