As the complement of getting the domain name out of a URL and get domain name from URL using javascript, here is another way to get domain name using javascript.
If you are running a script in a website you can find out the domain name of the website by using document.domain property.
var mydomain=document.domain;
Archive for April, 2009
Find Out The Domain Name of The Website
Javascript – Get URL Parameters
Here is a small function that will parse the window.location.href value and return the value for the parameter you specify.
<script type=”text/javascript”>
function get_url_parameter( param ){
param = param.replace(/[\[]/,”\\\[").replace(/[\]]/,”\\\]”);
var r1 = “[\\?&]“+param+”=([^&#]*)”;
var r2 = new RegExp( r1 );
var r3 = r2.exec( window.location.href );
if( r3 == null )??? return “”;
else??? return r3[1];
}
</script>
Suppose you have the following URL:
http://www.domain.com/index.html?test=123
And you want [...]
Get Domain Name From URL Using Javascript
We can find out the domain name from URL by using location.hostname property.
var mydomain=window.location.hostname;
or we can also use location.href property but it’s a little harder.
var mydomain=window.location.href.match(/:\/\/(.[^/]+)/)[1];
The hostname property can be set to redirect location, but it is safer to set the href property.
- MySQL Select Last n Records Without Changing The Order
- How to implement jQuery facebox plugin
- PEAR Install Spreadsheet_Excel_Writer
- PHP code to display Alexa rank
- PHP Configurations for Uploading File
- wp_insert_post could not insert post into the database
- PHP in_array() and array_search() functions
- Storing array data to MySQL using PHP
- How To Write print_r Output To File
- PHP Redirect Page
- mlotfi in Extjs PHP MySQL Simple Tutorial
- Nitin in Extjs PHP MySQL Simple Tutorial
- ber in Extjs PHP MySQL Simple Tutorial
- Avinash in PEAR Install Spreadsheet_Excel_Writ…
- paratenilesh in Extjs PHP MySQL Simple Tutorial
- yoube.info in Remove Mybrowserbar From My Browser…
- Alzuun in Remove Mybrowserbar From My Browser…
- RMK in Remove Mybrowserbar From My Browser…
- Laura in Remove Mybrowserbar From My Browser…
- Mitani in Remove Mybrowserbar From My Browser…
Niche Website Templates
This is a professionally designed website template package, it's ideal for sales pages, landing pages, squeeze pages and all kind of niche websites.
Cheapest Web Hosting- $7.99/Year. Host Unlimited Domains-$25.99/Year
Host Unlimited Domains, Unlimited Space, Unlimited BandWidth, Unlimited Database. With Self Installing Scripts, RV SiteBuilder. Cpanel Hosting. Ultra Fast Servers. Very Competitive Price. Customer Support Ticket. More Products Available.
Cheap PHP + MySQL ebook
Really cheap ebook (just 12$). Have a lot of information and examples about PHP and MySQL.
- Remove Mybrowserbar From My Browser
- Javascript - Get URL Parameters
- Fireworks: Make Rounded Corner Edges Image
- Get Domain Name From URL Using Javascript
- Hp Proliant ml350 g6 Win2003 Server Setup Bluescreen
- Merge Table Cells Using Javascript
- Extjs PHP MySQL Simple Tutorial
- Wp-O-Matic Plugin Cannot Add Campaign
- Javascript: Open new window containing php page
- Mozilla Firefox Add-ons for Downloading YouTube Video
- check string convert ip to number convert ip to numeric value copy table to a new table copy table using mysql dll file domain name domain name from url Export Data fireworks horizontal line effect get domain from url get url parameters golfer social network import data javascript alert javascript alert method javascript dialogue box javascript get url parameter javascript load php page javascript open new window javascript open php page javascript pops up javascript prompt javascript tabbed page JQuery Example location href merge table cells Motion Trail Text mysql copy table mysql ip to number PC Router php compress file php create zip file php error PHP fatal error php how to upload file php ip to number php session how to php uploaded file rounded corner edges image url domain url domain name WinXP auto logon WinXP File Sharing zip using php