Need help combining 2 Javascripts

This is a discussion on "Need help combining 2 Javascripts" within the JavaScript Forum section. This forum, and the thread "Need help combining 2 Javascripts are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 11th, 2007, 16:10
New Member
Join Date: Jun 2007
Location: my house
Age: 21
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Need help combining 2 Javascripts

I have to scripts (both in javascript) that need combining. One of them is a popup script and the other is a keycode script. So when there done being combined what has to happen is when you hit the 'alt' key it opens a popup. I'm not sure quite how to do this so any help would be greatly appreciated!

First script (key code):
Code: Select all
<script language="JavaScript">
document.onkeydown = function(e) {
if(!e) e = window.event;
if(e.altKey) {
parent.location.href = "http://www.google.com/";
}
}
</script>
Second Script (popup script):
Code: Select all
<script language="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=800,left = 212,top = -16');");
}
</script>
Thanks in advance!
Reply With Quote

  #2 (permalink)  
Old Jun 11th, 2007, 17:34
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Need help combining 2 Javascripts

In the first script you need to call the function out of the second script and pass it the url of the window you want opened. Like so:

Code: Select all
 <script language="JavaScript">
document.onkeydown = function(e) {
if(!e) e = window.event;
 if(e.altKey) {
  popUp("http://www.google.com/"); // or the url of the page you want to open in the popup
 }
}

function popUp(URL) {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=800,left = 212,top = -16');");
}
</script>
Reply With Quote
  #3 (permalink)  
Old Jun 11th, 2007, 18:09
New Member
Join Date: Jun 2007
Location: my house
Age: 21
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help combining 2 Javascripts

thanks!! worked perfectly!!
Reply With Quote
  #4 (permalink)  
Old Jun 11th, 2007, 19:22
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to c010depunkk
Re: Need help combining 2 Javascripts

no problem
Reply With Quote
Reply

Tags
javascript, key, key code, keycode, popup

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Are JavaScripts SEO Friendly? maneetpuri Search Engine Optimization (SEO) 4 Jan 16th, 2008 20:16
Over 2.000+ free JavaScripts temp Starting Out 0 Sep 5th, 2007 17:37
Help in combining two scripts jonnymorris JavaScript Forum 7 Jul 28th, 2007 15:20
Integrate Javascripts with toolbars JohnBT JavaScript Forum 7 Jun 18th, 2007 23:00
Combining fixed and relative widths hessodreamy Web Page Design 5 Feb 10th, 2006 13:14


All times are GMT. The time now is 10:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43