Results 1 to 5 of 5
  1. #1
    Administrator
    Montecristoe is offline

    Posts
    5,814

    Adding Javascript to php

    Hey I'm trying to insert executable javascript into the following php code, keeps giving me errors. Anyone know?

    Code:
    $tabselected = '';
    $tablinks = '';
    if (THIS_SCRIPT == 'yourpage')
    {
        $vbulletin->options['selectednavtab']='unique_name';
        $tabselected = ' class="selected"';
        $tablinks = '                <ul class="floatcontainer">
                            <li><a href="link1.php">Link 1</a></li>
                                <li class="popupmenu">
                                    <a href="javascript://" class="popupctrl">Drop Down</a>
                                    <ul class="popupbody popuphover">
                                            <li><a href="sublink1.php">Hip Hop</a></li>
                                            <li><a href="sublink2.php">Rock</a></li>
                                            <li><a href="sublink3.php">Pop </a></li>
                                    </ul>
                                </li>
                            <li><a href="link2.php">Rap</a></li>
                            <li><a href="link3.php">Country</a></li>
                    </ul> ';
    
    } 
    $template_hook['navtab_end'] .= '<li'.$tabselected.'><a class="navtab" href="javascript:music('http://buypoe.com/network/music.html','BP Music Channel','263','415','center','front');</a>'.$tablinks.'</li>' ; 



    I've included this in there as well at the top:

    Code:
    <SCRIPT LANGUAGE='JAVASCRIPT' TYPE='TEXT/JAVASCRIPT'>
    <!--
    var musicWindow=null;
    function music(mypage,myname,w,h,pos,infocus){
    
    if (pos == 'random')
    {LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    else
    {LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';musicWindow=window.open('',myname,settings);
    if(infocus=='front'){musicWindow.focus();musicWindow.location=mypage;}
    if(infocus=='back'){musicWindow.blur();musicWindow.location=mypage;musicWindow.blur();}
    
    }
    // -->
    </script>
    Something is going wrong. . .


    Similar Threads:
    How To: Use BuyPoe.com Trader System
    How To: Become an Official MM
    At [16] Posts - You Get BuyPoe Chat
    At [500] Posts - You Get Lifetime VIP



  2. #2
    Senior Member
    ratchet is offline

    Posts
    106
    either close the php:
    Code:
    ?><script>....</script><?php
    or use echo:
    Code:
    echo "<script>...</script>";



  3. #3
    Notion75 Guest
    You can always create a file with the html/javascript and then use the include function in PHP as such:

    Code:
    include 'file_location.html';



  4. #4

    Posts
    5,774
    I love programmers, you guys are awesome i looked at that and saw only letters, and symbols.






    If you cannot add me to MSN, or if I am not online sending me a PM or a vistor message is the best way to get an answer from me, or we can try to set up an MSN meeting, or talk on skype etc etc.

  5. #5
    Junior Member
    elliottedgar87 is offline

    Posts
    0
    Nice to know that we are liked. You need to close of the php bit from what I can see. Are you working on Dreamweaver because it will tell you the error.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright © 2009-2012 BuyPoe.com All Rights Reserved.

Design Sites:
vBulletin Mods
Facebook Covers
| Free Facebook Covers
Google Covers | Google Plus Covers

Game Sites:
MMORPG
| MW3