开发者

Javascript won't run properly in PHP

So, first off. It runs fine on another webserver: http://colorsnatcher.com/cuse/feedback.html

won't work here: http://campusbasement.com/contact.php#

When I want to implement it into my site, the javascript doesn't run properly.

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' placeh开发者_JS百科older="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>

error:

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

EDIT: I figured it out. It was conflicting with other scripts therefore instead of using $, I had to use jQuery.


JavaScript does not run within PHP. JavaScript is interpreted by your web browser. PHP just includes the HTML snippets (including the <script /> tags).

If your JavaScript does not work, try to debug it with Firebug or something similar.


FWIW.... check HTML document types. I have had many issues writing Javascript that works fine on one server, and no on another and it frequently because of the default document type on that server (XHTML vs HTML5 for example)


had to use

jQuery(function() {

});

instead of $


Have you tried wrapping this in $(document).ready(...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜