Activity Stream
48,167 MEMBERS
6838 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1
    Member
    Website's:
    maxneeds.info

    Default [JS] indexof prob

    Hi !
    I have the following function :
    Code: 
    <script>function hide(){
    var str=document.location.href;
    if(str.indexOf(\"?to=\"))
    {document.getElementById('vip').style.display='none';}
    }</script>
    I am trying to hide an object if in the url contains '?to=' .
    But this one is hiding it always.
    Any help ?
    Porsche_maniak Reviewed by Porsche_maniak on . [JS] indexof prob Hi ! I have the following function : <script>function hide(){ var str=document.location.href; if(str.indexOf(\"?to=\")) {document.getElementById('vip').style.display='none';} }</script> I am trying to hide an object if in the url contains '?to=' . But this one is hiding it always. Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    Elite.SO Defendos.com Motionite.com
    This is a small code that I use in my templates to show/hide something.

    Save this file as "slide.js"
    Code: 
    //////////////////////////////////////////////////////////////////////////////
    // slide.js Example
    //////////////////////////////////////////////////////////////////////////////
    
    var Hide = "";
    var varHt = 0;
    var Ht = "";
    var x = 0;
    var y = 10;
    var z = 4;
    var foo = new Array();
    var Speed = "";
    
    function setup() {
        foo = document.getElementsByTagName("div");
        for (i=0;i<foo.length;i++) {
            if (foo[i].className == "hidden") {
                Hide = foo[i].id;
            }
        }
        Ht = document.getElementById(Hide).offsetHeight;
        Speed = Hide.substring(Hide.lastIndexOf('-')+1);
        document.getElementById(Hide).style.height = '0px';
        document.getElementById('toggle').style.display = 'inline';
        
        if (Speed == 1) { y = 100; z = 1; }
        if (Speed == 2) { y = 70; z = 1; }
        if (Speed == 3) { y = 40; z = 1; }
        if (Speed == 4) { y = 20; z = 1; }
        if (Speed == 5) { y = 10; z = 1; }
        if (Speed == 6) { y = 10; z = 2; }
        if (Speed == 7) { y = 10; z = 4; }
        if (Speed == 8) { y = 10; z = 7; }
        if (Speed == 9) { y = 10; z = 10; }
    }
    
    function toggle() {
        if (x === 0) {
            document.getElementById(Hide).style.height = varHt+'px';
            if (((Ht-varHt) < z) && (varHt !== Ht)) {
                varHt = Ht;
            } else {
                varHt = varHt+z;
            }
            if (varHt <= Ht) {
                setTimeout('toggle()',y);
            }
            if (varHt > Ht) {
                varHt = Ht;
                x = 1;
            }
        } else {
            document.getElementById(Hide).style.height = varHt+'px';
            varHt = varHt-z;
            if ((Ht-varHt) <= Ht) {
                setTimeout('toggle()',y);
            }
            if ((Ht-varHt) > Ht) {
                varHt = 0;
                document.getElementById(Hide).style.height = varHt+'px';
                x = 0;
            }
        }
    }
    Paste this in your page <head> tag:
    Code: 
    <script type="text/javascript" src="menu.js"></script>
    in same page use this where you want the "hidden" shizzle:
    Code: 
    <a href="#" id="toggle" onclick="toggle();"><strong>Show/Hide</strong></a>
    <div id="hidden" class="hidden">
    echo "text here, this will be hidden, after you click Show/Hide it will show up."
    </div>

    Defendos BETA3 Released! Thread - Official Website

  4.     
    #3
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Code: 
    function _$(id){return document.getElementById(id) || undefined;}
    
    var a_uri = document.location.href || '';
    if(a_uri.indexOf("?to="))
    {
        elem = _$('vip');
        if(elem != undefined)
        {
            elem.style.display = 'none'
        }
    }
    Why are you using escape chars for the quotes ?
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  5.     
    #4
    Member
    Website's:
    maxneeds.info
    Thanks litewarez i already solved it with
    Code: 
    <script type=text/javascript>function hide(){if (document.location.href.indexOf('?to=') >= 0){document.getElementById('vip').style.display='none';}}hide();</script>
    Btw the slide.js you gave is really interesting thanks !

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. help me plz dle prob
    By fahadzaman66 in forum Webmaster Discussion
    Replies: 10
    Last Post: 15th Oct 2011, 02:12 AM
  2. ipb seo 1.1 prob
    By FSL in forum IP.Board
    Replies: 12
    Last Post: 25th May 2011, 04:48 PM
  3. RL Mtn prob
    By Chris2k in forum Technical Help Desk Support
    Replies: 1
    Last Post: 10th Jan 2011, 12:53 AM
  4. Prob With my PC :| (Help!!)
    By vizoomer in forum Technical Help Desk Support
    Replies: 19
    Last Post: 12th Aug 2010, 07:32 AM
  5. CSS IE6 prob
    By Porsche_maniak in forum Web Development Area
    Replies: 1
    Last Post: 5th Jun 2010, 10:06 AM

Tags for this Thread

BE SOCIAL