Solved

Two basic javascript questions - amend font and get ip/hostname

Posted on 2004-10-01
14
529 Views
Last Modified: 2013-12-03

Is there a way of obtaining the ipaddress and hostname of my machine using javascript and insert it into a redirect?, like this :
<script language="Javascript">
alert ("Selected Contracts Have Been Completed")
window.location="http://<my ip address>:8080/somepage.jsp";
</script>

Also how can I change the font and size of the text displayed in the alert?

Im using windows XP

Thank you
0
Comment
Question by:CtrlCtrlV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
  • +2
14 Comments
 
LVL 12

Expert Comment

by:monosodiumg
ID: 12198768
DO you mean the ip of the client? Hostname doesn't make sense for the client.
0
 

Expert Comment

by:michaelfriesy
ID: 12198832

No the ip of the hose machine , ie the machine the javascript code is on.
0
 

Expert Comment

by:michaelfriesy
ID: 12198834
>>hose,
I mean host
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:monosodiumg
ID: 12198862
The host the page is served from?

You can get that from the Location object:
window.Location.hostname
0
 

Expert Comment

by:VolSpeak
ID: 12198878
This would work?

window.location="http://window.Location.hostname:8080/somepage.jsp";
0
 
LVL 12

Expert Comment

by:monosodiumg
ID: 12198909
No it won't. It would be:

window.location="http://" + window.Location.hostname + ":8080/somepage.jsp";

0
 

Expert Comment

by:VolSpeak
ID: 12198920
Ok, ill try that

>>Also how can I change the font and size of the text displayed in the alert?
0
 
LVL 12

Expert Comment

by:monosodiumg
ID: 12198975
You can't. The alert is provided by the OS and you can't control anything except the text.
If you ned something prettier, you can make up your own using window.open to open anew window then document.write to write HTML into it.
0
 

Expert Comment

by:VolSpeak
ID: 12198992

>>window.location="http://" + window.Location.hostname + ":8080/somepage.jsp";

That doesnt work for me, it just brings me to this url:
http://undefined.cc/
0
 

Expert Comment

by:VolSpeak
ID: 12199001
>>If you ned something prettier, you can make up your own using window.open to open anew window then document.write to write HTML into it.

Any simple examples?
0
 
LVL 12

Expert Comment

by:monosodiumg
ID: 12199195
You could grab one that suits your needs from http://www.pacosdrivers.com/wm/js.asp?cat=1.
This one looks suitable: http://www.dynamicdrive.com/dynamicindex11/abox.htm

A simple example can be found in this discussion:
http://www.webxpertz.net/forums/archive/index.php/t-9699.html

0
 

Expert Comment

by:marshmeli
ID: 12201137
>>That doesnt work for me, it just brings me to this url:
>>http://undefined.cc/

hmm, that should work try just "location.hostname"

in the browser window you can test the statement by typing:

javascript:[statement];

and try

javascript:[window.location.hostname];
and
javascript:[location.hostname];

they should both give the same result, and print the host address...
0
 
LVL 12

Accepted Solution

by:
monosodiumg earned 200 total points
ID: 12205182
Location -> location
My typo. sorry.
0
 

Author Comment

by:CtrlCtrlV
ID: 12809717
thats fine, thank a mil and sorry about taking so long to get back :)
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Provide the IDEA of External JS 1 41
Popup write two lines 3 22
Why is my $_POST not going to results page 10 41
Slush on text 2 12
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question