?
Solved

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

Posted on 2004-10-01
14
Medium Priority
?
534 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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

770 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