Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Need some javascript help

  1. #1
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Need some javascript help

    So I'm trying to make it that when reload=1 is added to the URL, the page refreshes upon doing this one action. I know it works if I don't check if reload=1. But I can't figure out how to check.
    BTW, I don't know a thing about javascript. I did this by copying some code

    Here is what I have. But it doesn't work.
    Code:
    var queryString = url.replace(/^[^\?]+\??/,'');
    var params = tb_parseQuery( queryString );
    Code:
    if(params['reload'] == 1){
    	location.reload(true);
    }
    Thanks for any help! There might be a credits reward ;)
    Last edited by Christopher; 07-03-2008 at 11:38 PM.

  2. #2
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: Need some javascript help

    Try using this instead:

    Code:
    if (location.search.match('reload=1')) {
        location.search = location.search.replace(/&?reload=1/, '');
    }
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  3. #3
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Re: Need some javascript help

    Nope.
    I am able to get parameters from the URL.

    Code:
    TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
    TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
    That works.
    Last edited by Christopher; 07-04-2008 at 12:57 AM.

  4. #4
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: Need some javascript help

    Oh so you *want* to use the params variable? Well in that case I need to see the definiton for the url variable.
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  5. #5
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Re: Need some javascript help

    Not quite sure want you want to see.
    You can view the full code (without my attempted refresh thing) at http://jquery.com/demo/thickbox/

  6. #6
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: Need some javascript help

    Alright, so you're placing that code inside of the tb_show() function? At which part exactly? Right after this code?

    Code:
    var queryString = url.replace(/^[^\?]+\??/,'');
    var params = tb_parseQuery( queryString );
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  7. #7
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Re: Need some javascript help

    I put it in tb_remove()

    Code:
    function tb_remove() {
     	$("#TB_imageOff").unbind("click");
    	$("#TB_closeWindowButton").unbind("click");
    	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
    	$("#TB_load").remove();
    	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
    		$("body","html").css({height: "auto", width: "auto"});
    		$("html").css("overflow","");
    	}
    	document.onkeydown = "";
    	document.onkeyup = "";
    	if(params['reload'] == 1){
    		location.reload(true);
    	}
    	return false;
    }

  8. #8
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: Need some javascript help

    Ah, that's most likely your problem then since params isn't defined there.

    Try changing it to this:

    Code:
    function tb_remove() {
         $("#TB_imageOff").unbind("click");
        $("#TB_closeWindowButton").unbind("click");
        $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
        $("#TB_load").remove();
        if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
            $("body","html").css({height: "auto", width: "auto"});
            $("html").css("overflow","");
        }
        document.onkeydown = "";
        document.onkeyup = "";
        var queryString = location.href.replace(/^[^\?]+\??/,'');
        var params = tb_parseQuery( queryString );
        if(params['reload'] == 1){
            location.reload(true);
        }
        return false;
    }
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

  9. #9
    Christopher's Avatar
    Christopher is offline Retired Christopher is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    USA
    Posts
    7,330

    Re: Need some javascript help

    Still not working.

  10. #10
    woiwky is offline x10 Lieutenant woiwky is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    390

    Re: Need some javascript help

    Try adding 'alert(location.search);' right before 'var queryString...'. If you get no alert box or if you don't see reload=1 in the message, then the code isn't the problem. I just wanna narrow down exactly what the problem is.
    "But you have access to the greatest source of knowledge in the universe."
    "Well I do talk to myself sometimes, yes."

    "I'm back, and I'm bad! Obviously within certain, sensible, preset parameters"

Closed Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  2. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  3. A question about javascript files
    By rlodge in forum Programming Help
    Replies: 6
    Last Post: 12-19-2007, 11:26 AM
  4. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 AM
  5. Some nice-simple JavaScript effects !!
    By careerbridge in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 07-13-2006, 08:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers