scriptygoddess

02 Mar, 2003

Launching new windows, or brining focus to windows already launched…

Posted by: Jennifer In: Scripts

This partially in response to some modification requests to the smilie launch… This script will launch a new window. If/when it looses it's focus (ie. it's in the background) if the person clicks the link again, rather than launching a *new* window, or appearing to do nothing at all, this will bring the (previously launched) window to the front – or launch a new one if it had been closed…

So, first, in response to the "Lazyman's Smilies" – use this instead to launch your smilie palette (a minor update was added so that you don't lose your "spot" on the page):

<a name="smilieLaunch"></a>
<a href="#smilieLaunch" onClick="openAWindow('/smilies/index.php','smilies','scrollbars=yes,width=400,height=300')">Add a smilie</a> (launches smilie 'palette')

Then any page that you have the ability to launch that smilie palette, put this code somewhere between your <head> </head> tags…

<script language="JavaScript">
<!–
var ANewWindow = null; // new
function openAWindow(theURL,winName,features) { //v2.0
// check if window already exists
if (!ANewWindow || ANewWindow.closed) {
// store new ANewWindow in global var
ANewWindow = window.open(theURL,winName,features);
} else {
ANewWindow.location = theURL;
ANewWindow.focus();
}
}
//–>
</script>

As well, you'll now want to make it so that the smilie palette doesn't automatically close once somone clicks on a smilie… so in that smilieIndex.txt code… comment out the following two lines:

self.opener.window.document.<? echo $commentsFormName; ?>.<? echo $commentsTextName; ?>.focus();
window.close();

like this:

// self.opener.window.document.<? echo $commentsFormName; ?>.<? echo $commentsTextName; ?>.focus();
// window.close();

[ Thanks to Doc for his help and Sandman for his tutorial on using this on your edit_entry.tmpl ]

[ an additional note – I did NOT write the javascript function… a co-worker at a former job I had did ]

17 Responses to "Launching new windows, or brining focus to windows already launched…"

1 | Doc

March 2nd, 2003 at 9:37 pm

Avatar

Thanks for the fix!
And thanks for the credit, although I really didn't do anything other than butcher your code.

It wants to reload the window when it gets re-focused, BTW.

2 | The Sandman

March 2nd, 2003 at 9:55 pm

Avatar

Thank you for the credit.

3 | Jennifer

March 2nd, 2003 at 10:23 pm

Avatar

Doc, unfortunately, I can't think of a way around it… I tried having it check the URL of the loaded window but it still seems to try and "reload" it…

I'm going to post a minor update… since the href is set to just "#" it sends you to the top of the comments page… so I'm going to make a minor fix so that you don't lose your place.

4 | Doc

March 2nd, 2003 at 10:29 pm

Avatar

I made a minor fix to that where I just changed the name pointer from # to whatever the form name was I was wanting focus on.

in my coments pop up it says href="#comments_form" Works just fine.

The reloading window is a minor point. I wouldn't have eve noticed if I hdn't seen it "blink."

Thanks again.

5 | Cathy

March 2nd, 2003 at 10:32 pm

Avatar

Some excellent help here, will be back :)

6 | dainec

May 16th, 2003 at 10:46 am

Avatar

Hi there! I'm getting an error… the palette shows up when it should, but nothing happens when you click on an image. I didn't change the code except for the modifications that you listed. (I'm using MT 2.63.)

Thank you for any help or advice you can offer!

7 | dainec

May 16th, 2003 at 11:42 pm

Avatar

I figured it out… my comments form was named "comments_form" – not "comments" – worked like a charm once I fixed it!

8 | Lisa

May 26th, 2003 at 1:06 pm

Avatar

Yay!! Thanks! I'm loving this!

9 | ali

January 24th, 2004 at 12:58 am

Avatar

hi.. first of all, i want to thank you for this script.. and for tihs site.. i'm just starting my page, but i know i'll be appreciating this site as i go, and singing you praises along the way. okay, so about this smilies script..i'm pretty sure i have most all of it right.. i did make sure i have 'html allowed in comments'.. all works flawlessly EXCEPT: when i click on a smiley, the 'img' tag shows properly, but then when i post or preview, none of the smilies show; they're blank. :-/ i really would think that would be a "allow html" issue.. but i do have my settings set to allow… might you know what i'm missing? thanks in advance..
(if you need to get into the site, username: 'script'; password: 'g' …like i said, the site's just beginning, so it's not 'public' as yet.)

10 | Jennifer

January 24th, 2004 at 8:03 am

Avatar

Just clicking "allow html" won't allow img tags in your comments. There's another MT setting called "Sanitize Spec" which will remove tags you don't allow. (the default removes img tags) You need to change the default setting (which is to use their settings) to customize… then enter the tags you want to allow in your comments in the field. Here's what I have on my personal blog:
i, a href target, b, br, p, strong, em, ul, li, blockquote, img src width height, h3

11 | ali

January 24th, 2004 at 11:39 am

Avatar

hem. and i went and posted to the wrong entry while i was at it 😉
in any case, thank you so much for your help! of course it works beautifully now.. very very much appreciated!

12 | dainec

May 18th, 2004 at 11:01 pm

Avatar

I'm trying to get this to work with WordPress … so far, the palette comes up with no problem, but nothing happens when I click on the smilies. I'm thinking that I might have the wrong values in these variables:
$commentsFormName = "comments_popup_link";
$commentsTextName = "comment";

Should the FormName be the name of the file (i.e. wp-comments-popup.php)?

13 | Fire When Ready!!

March 4th, 2003 at 6:20 am

Avatar

This and that
Well my comments should be fied now,For some reason it was not saving the info but like I said it…

14 | Bloggie Broad

October 6th, 2003 at 7:46 pm

Avatar

Fun with Scripts and Stuff
I try to mention what scripts, plugins, etc. I add to BB in case someone else wants to grab 'em. The majority of the Scriptygoddess'…

15 | Bloggie Broad

October 8th, 2003 at 12:43 am

Avatar

Reverb: Bloggie Scripty Fun
I'm organizing BB and deleted the posts revolving around my techie mess from earlier in the week, since it was an easy fix. I like…

16 | Bloggie Broad

November 23rd, 2003 at 5:49 pm

Avatar

Reverb: Bloggie Scripty Fun
I'm organizing BB and deleted the posts revolving around my techie mess from earlier in the week, since it was an easy fix. I like…

17 | Liam

May 7th, 2005 at 11:44 am

Avatar

Hi ive tried to get the above code working but have a bit of a problem i get the smilies pallet to open up and it has the table but the images dont show up and i have an error saying Notice: Undefined variable: retVal in the index.php file on line 46 does any1 know why this would be happening.
Thanx

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements