2010-11-18 209 views
-1

所以,首先。它運行在另一個網站服務器罰款: http://colorsnatcher.com/cuse/feedback.htmlJavascript將無法正常運行在PHP

不會在這裏工作: http://campusbasement.com/contact.php#

當我想落實到我的網站,javascript的運行不正常。

Contact.php

<?php include('feedback.php'); ?> 

feedback.php

 <script src="http://www.campusbasement.com/scripts/jquery-1.4.2.min.js" type="text/javascript"></script> 
<script src="http://www.campusbasement.com/scripts/tab.js" type="text/javascript"></script> 
<link rel="stylesheet" href="http://www.campusbasement.com/feedback/feedback.css" type="text/css" /> 
<script type="text/javascript"> 
    $(function(){ 
     $("#slide-out-div").tabSlideOut({ 
      tabHandle: '#handle',      //class of the element that will become your tab 
      pathToTabImage: 'http://www.campusbasement.com/feedback/report.png', //path to the image for the tab //Optionally can be set using css 
      imageHeight: '160px',      //height of tab image   //Optionally can be set using css 
      imageWidth: '40px',      //width of tab image   //Optionally can be set using css 
      tabLocation: 'left',      //side of screen where tab lives, top, right, bottom, or left 
      speed: 300,        //speed of animation 
      action: 'click',       //options: 'click' or 'hover', action to trigger animation 
      topPos: '200px',       //position from the top/ use if tabLocation is left or right 
      leftPos: '20px',       //position from left/ use if tabLocation is bottom or top 
      fixedPosition: true      //options: true makes it stick(fixed position) on scroll 
     }); 
    }); 

    </script> 
    <div id="slide-out-div"> 
     <a id="handle" href="#"><div id="reportImage"></div></a> 
     <div id="contactform"> 
       <form method="post" action="http://www.campusbasement.com/feedback/contactengine.php"> 
        <input id='name' name='name' type='text' placeholder="Name" > <br /> 
        <input id='Email' name='Email' type='text' placeholder="Email" > <br /> 
<br /> 
        <textarea name="Message" rows="5" cols="15" id="Message" placeholder="Bugs? Suggestions?"></textarea><br /> 

        <input type="submit" name="submit" value="Submit" class="submit-button" /> 
       </form> 
     </div> 

    </div> 

錯誤:

contact.php:246Uncaught TypeError: Object #<an Object> has no method 'tabSlideOut' 

編輯: 我想通了。它與其他腳本衝突,因此而不是使用$,我不得不使用jQuery。

+3

你的問題是什麼?什麼不行?另外我真的不認爲它與PHP有關 - 瀏覽器中運行的是生成的HTML – 2010-11-18 21:35:55

+1

「無法正常運行」是什麼意思?你看到什麼錯誤或意外的行爲? – BenV 2010-11-18 21:36:37

+0

FireBug報告:$(「#slide-out-div」)。tabSlideOut不是函數 – 2010-11-18 21:36:39

回答

0

不得不使用

jQuery(function() { 

}); 

而不是$

1

JavaScript不能在PHP中運行。 JavaScript由您的網絡瀏覽器解釋。 PHP只包含HTML片段(包括<script />標籤)。

如果您的JavaScript不起作用,請嘗試使用Firebug或類似的東西進行調試。

0

你嘗過$(document).ready(...

+0

I beleive $(function(){});相當於$(document).ready – Matt 2010-11-18 21:40:32

+0

是的,我有----- – switz 2010-11-18 21:41:28

0

FWIW這個包裹檢查.... HTML文檔類型。我有很多問題編寫JavaScript是一臺服務器上工作得很好,並沒有對另一個而且常常因爲該服務器上的默認文檔類型(XHTML VS HTML5例如)