• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Total newbie.....Javascript window opener

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know NOTHING about Javascript. I'll try to be brief and clear.

I'm creating a website with a list of members. Each member (total of 10) will have their own picture. What I want to do is make the picture a hyperlink to open a new window.

That's easy enough - but my intent is for the new window to be small in size and not have any of the menus or toolbars of a standard window.

Through a fair amount of Googling, I came accross the following code (made with a code generator). Now I know the code works - and works the way I want.

What I don't know is how to incorporate this into the existing pages so the pictures act as hyperlinks opening the window.

Any help is appreciated.

<script language="JavaScript" type="text/javascript">
<!--
function open_win(what_link){
var the_url = "http://home.neo.rr.com/vroberts/Image_Window.htm"
var the_x = 900;
var the_y = 620;
the_x -= 0;
the_y -= 0;
var how_wide = screen.availWidth;
var how_high = screen.availHeight;
if(what_link != ""){the_url=what_link;}
var the_toolbar = "no";
var the_addressbar = "no";
var the_directories = "no";
var the_statusbar = "no";
var the_menubar = "no";
var the_scrollbars = "no";
var the_do_resize = "no";
var the_copy_history = "no";
top_pos = (how_high/2) - (the_y/2);
left_pos = (how_wide/2) - (the_x/2);
if (window.outerWidth ){
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",outerWidth="+the_x+",outerHeight="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open(the_url, "DisplayWindow", option);
var Opera = (navigator.userAgent.indexOf('Opera') != -1);
if(Opera){
site.resizeTo(the_x,the_y);
site.moveTo(0,0);
}
}
else
{
var option = "toolbar="+the_toolbar+",location="+the_addressbar+",directories="+the_directories+",status="+the_statusbar+",menubar="+the_menubar+",scrollbars="+the_scrollbars+",resizable="+the_do_resize+",Width="+the_x+",Height="+the_y+",copyhistory="+the_copy_history+",left="+left_pos+",top="+top_pos;
site=open('', "DisplayWindow", option);
site.location=the_url;
if(site.open){site.focus();return false;}
site.resizeTo(the_x,the_y);
}
}
// -->
</script>
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hugh,

Welcome to JavaRanch!

Let me start off by teaching you one important thing about JavaScript: it's totally, utterly, completely, unquestionably unrelated to Java. They're both programming languages, and they both have niches in Web programming, but that's about it.

Now, JavaRanch is mostly about Java, not JavaScript. But we do have one forum where JavaScript is on-topic: it's our HTML and JavaScript forum. And there's actually a dyed-in-the-wool JavaScript wizard who runs the place. I'm going to move this thread over to that forum, where you'll surely get the help you need. Just follow the link above to find your moved message.

See you around the Ranch!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<img src="blah.jpg" onclick="open_win('theLink')">
 
Hugh Syme
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric - thanks for the quick response.

The code I posted specifies window size, position & toolbar attributes. That's the important thing to me.

As you can tell - I know SQUAT about true coding. Here's the site: www.specializedohio.com/members.htm

Each person's image (or name) should be a hyper link to open a 900x600 in the center of the screen.

I appreciate any help.
[ December 23, 2004: Message edited by: Hugh Syme ]
reply
    Bookmark Topic Watch Topic
  • New Topic