Skip to main content

Posts

Showing posts from 2012

URL Parameters & JavaScript

Diogenes Painting by Jean Leon Gerome T oday I was in need of a simple solution to get targeted parameters to a HTML page I'm in a platform that only accepts a page as home page HTML. In my case my login page. I needed that if the login had not success, then one message would be passed to this same page be reloaded,  reading and showing  the message. I did not want to create a second page that is always overlooked when changing the layout or css. After a little search I wrote the follow code: to use, create a HTML file like: parametro.html open with your browser, type something like: file:///yourfolder/parametro.html?param=Hello World&param2=21/12/1966 <!DOCTYPE HTML> <HTML LANG="pt-br"> <HEAD> <SCRIPT> /**  * Example of how to read the parameters of   * a URL when loading a page using javascript  * @author Nivio dos Santos  * @version 1.0  */ /**  * Creating namespace in order to avoid naming conflict.  */ niv