Solved

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

Posted on 2004-10-01
14
525 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now