Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2004-10-01
14
Medium Priority
?
539 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
  • 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
Independent Software Vendors: 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 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article discusses how to implement server side field validation and display customized error messages to the client.
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)
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

564 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