Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reload page with parameters javascript

/**
 * Si le paramètre est nul, recharge la page, sinon recharge la page avec le paramètre.
 * If the parameter is null, reload the page, else, reload the page with the parameter
 * @param [param=null] - Le paramètre que vous souhaitez ajouter à l'URL.
 */
function reloadPage(param = null){

    if ( param != null ){
        window.location.href = window.location.href.replace( /[?#].*|$/, `${param}` );
    }

    else
    { 
        if ( window.location.href.split('?').length > 1 ){
            window.location.href = window.location.href.split('?')[0];
        }

        else 
            window.location.reload();
    }

    //param == null ? window.location.reload(): window.location.href = window.location.href.replace( /[?#].*|$/, `${param}` );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript remove last element from array 
Javascript :: jQuery on right mouse click 
Javascript :: angular 9 dockerfile 
Javascript :: how to auto refresh a div js 
Javascript :: how to convert string into blob in javascript 
Javascript :: how to go back to previous page after updating data in jquery 
Javascript :: print object key value javascript 
Javascript :: how to set html label value in jquery 
Javascript :: getting form values in javascript 
Javascript :: js promisify in browser 
Javascript :: convert response to json javascript 
Javascript :: react-native-permissions could not be found within the project or in these directories: 
Javascript :: convert string in ethers.js 
Javascript :: mongoose get raw 
Javascript :: width and height in js 
Javascript :: discord.js guildMemberAdd 
Javascript :: javascript file drag and drop 
Javascript :: Html2Canvas screenshot and download 
Javascript :: inject image javascript 
Javascript :: js copy span text to clipboard 
Javascript :: npm run shell script 
Javascript :: remove an element from an array javascript 
Javascript :: how to render a new page in node js through express 
Javascript :: validate phone number regex 
Javascript :: jquery serialize with file upload 
Javascript :: get $_get in javascript 
Javascript :: fetching iframe content JS 
Javascript :: json enum string 
Javascript :: how to add css in js 
Javascript :: javascript add 1 day to new date 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =