SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Javascripts

  1. #1
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,891
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Javascripts

    Hello,
    I have two javascripts trying to execute on everypage of my site and i have the 2 <script> tags in the head of the pages and they link to .js files in a js folder. Both of the scripts needed to reference other files in a js folder so i put all the referencable files in 1 single js folder. But the two scripts seem to be conflicting? Is there a way to stop that?

    Thanks

    Neil

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. there seems to be variables in both js files with the same name. Therefore the conflict. Another reason is that both scripts have window.onload in them. Meaning that the first one will be overwritten.

  3. #3
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,891
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How could i overcome this so i can have them both running like I need.

    Thanks

    Neil

  4. #4
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If theyt are both using the window.onload event, you will need to wrap them both in to a single function and call it. If they share variable/function names, you will need to rename some of them.

    If you post the two scripts here we should be able to help relatively easily.

    Regards,
    Jordan

  5. #5
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,891
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,
    These lines are the bits in the footer of thew page where the javascripts show there result:

    <p class="center"><a href="index.php?page=credits">Copyrights Details &amp; Credits</a> | <a href="javascript:show()">Add Content To This Page</a>


    <!--<div id="doc" style="font-family: Arial, Helvetica, sans-serif; font-size: 12px">
    <div id="online"><strong>People Online</strong>: 0</div>
    </div>-->

    and below is the code in the head of the pages:

    <script type="text/javascript" src="/javascripts/prototype.js"> </script>
    <script type="text/javascript" src="/javascripts/window.js"> </script>
    <script type="text/javascript" src="/javascripts/effects.js"> </script>
    <link href="themes/alphacube.css" rel="stylesheet" type="text/css"> </link>
    <link href="/themes/default.css" rel="stylesheet" type="text/css" > </link>

    <!--Code for ADD CONTENT POPUP PAGE-->
    <script type="text/javascript">
    function show(){
    win = new Window('window1', {className: "alphacube", resizable: true, title: "Add Content To This Page", resizable: true, url: "<?php echo $addurl; ?>//", width:600, height:500});
    win.setDestroyOnClose();
    win.showCenter();
    }
    </script>

    <!--REAL TIME PEOPLE ONLINE COUNTER-->
    <!--<script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/spy.js" type="text/javascript"></script>

    <script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
    $('#doc').spy({ limit: 1, fadeLast: 0, ajax: 'doc.php', timeout: 3000});
    });
    </script>-->

    The two scripts do the following:

    1 - Shows a popup box thingy with another website inside!

    2 - Is an ajax developed dynamic online people counter.

    One of the javascrpts is currently commented out so that I can use one but i would like to have both running at the same time!

    Thankyou


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •