2010-11-18 207 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例如)