2011-06-12 9 views
1

内のJavaScriptのロード順の問題、私は含まれていwebpage.packing.php PHP構築しようとしています:クリーンURLとPHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
     <meta name="description" content="Fresh Sliding Thumbnails Gallery with jQuery and PHP" /> 
     <meta name="keywords" content="jquery, images, gallery, full page, thumbnails, scrolling, sliding, php, xml"/> 
     <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/> 


<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" /> 

<script type="text/javascript" src="js/jquery-1.6.1.js"></script> 


<link rel="stylesheet" type="text/css" href="css/site.css" /> 

<script type="text/javascript" src="js/ddsmoothmenu.js"> 

</script> 
     <script type="text/javascript" src="js/jquery.gallery.js"></script> 

<script type="text/javascript" > 
$(document).ready(function(){ 


    // Menu 

    ddsmoothmenu.init({ 
    mainmenuid: "smoothmenu1", //menu DIV id 
    orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v" 
    classname: 'ddsmoothmenu', //class added to menu's outer DIV 
    //customtheme: ["#1c5a80", "#18374a"], 
    contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"] 
}); 
}); 

</script> 

を、私の.htaccessは今、私は私を開いたときに

RewriteEngine On 
RewriteRule ^packing/Pure packing.php?id=pure 
RewriteRule ^packing/ExtraVirgin packing.php?id=EV 

ですphpレンダリングが正しく実行されていることを示しています。

ただし、クリーンURLを使用して開くと、$が定義されていないという警告が表示されます。

私は問題がjavascriptsの読み込み順序が間違っていることが原因であることを知っています。 なぜそれが起こるのですか?どのように解決できますか?

ありがとうございます。

答えて

2

クリーンURLを使用すると、ブラウザは別のディレクトリ(/packing/pure)にあると判断します。 JSファイルを指す相対URLはもはや機能しません。代わりに

使用絶対URL:

<script type="text/javascript" src="/js/jquery.gallery.js"> 
2

パスに問題があるだろうか?あなたはパスを与えていませんが、ルート(packing.php)から2番目のレベル(packing/Pure)にパスを変更しています。おそらく/jsの代わりにpacking/js/のように間違ったパスで.jsファイルを探している可能性があります。

あなたの読み込みのための絶対パスを使用してみてください:

<script type="text/javascript" src="/js/jquery-1.6.1.js"></script> 

(スラッシュに気づく!)
あるいは

<script type="text/javascript" src="http://yoursite.com/js/jquery-1.6.1.js"></script> 
+0

申し訳ありませんが、正しい両方の答えをマークすることができませんでした...どうもありがとう –

+0

ありません問題のofcourse :) – Nanne

関連する問題