JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 24th, 2001, 09:10 AM
GRaPHiX_FReaK GRaPHiX_FReaK is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Nottingham - England (UK)
Posts: 9 GRaPHiX_FReaK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to GRaPHiX_FReaK
Heya guys, I need help with this script, I can get it to pop up on page load, But cant stop that to make it pop up on a link command.

I have page that loads a Pop up window on load which is DHTML and is dragable.

The script:

<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">
<!--
// This script handles the dragging and closing capabilities
// of the DHTML popup

//Declare, set global variables

var selectedObj
var offsetX, offsetY
var divPosX, divPosY

//Set the initial X,Y coords for the popup div
divPosX = 15;
divPosY = 15;

//Detect browser verssion
var IE4
var coll, styleObj

IE4 = (document.all) ? 1 : 0;

if (IE4){
coll = "all.";
styleObj = ".style";
}

//return the DOM reference to the given style
function getObject(obj) {
var objRef
if (typeof obj == "string") {
objRef = eval("document." + coll + obj + styleObj);
} else {
objRef = obj;
}
return objRef;
}

//Close the DHTML popup window
function hideElement(obj) {
divRef = getObject(obj);
divRef.visibility = "hidden";
//event.srcElement.style.cursor = "pointer";
}

//Shift an object to given position
function shiftTo(objRef, Xpos, Ypos) {
objRef.pixelLeft = Xpos;
objRef.pixelTop = Ypos;
}

//Only allow IE4+ to initialise DHTML popup, else display normal HTML popup window
function init() {
if (IE4) {
initEvtHandling();
initDiv('dhtmlpopup');
} else {
showHTMLPopup();
}
}

function showHTMLPopup() {
myWindow = window.open("popupURL","NAME","titlebar=no,HEIGHT=170,WIDTH=180");
myWindow.moveTo(200,200);
myWindow.focus();
}

//Assign the event handlers
function initEvtHandling() {
document.onmouseup = releaseElement;
document.onmousemove = moveElement;
}

//Initialise the div
function initDiv(obj) {
divRef = getObject(obj);
shiftTo(divRef, divPosX, divPosY);
divRef.visibility = "visible";
}

function grabElement(obj,evt) {
selectedObj = getObject(obj);
calculateOffsets(evt);
return false;
}

function calculateOffsets(evt) {
mousePosXRef = window.event.clientX;
mousePosYRef = window.event.clientY;
offsetX = mousePosXRef - divPosX;
offsetY = mousePosYRef - divPosY;
}

function moveElement(evt) {
if (selectedObj) {
mousePosXRef = window.event.clientX;
mousePosYRef = window.event.clientY;
divPosX = mousePosXRef - offsetX;
divPosY = mousePosYRef - offsetY;

shiftTo(selectedObj,divPosX,divPosY);
return false;
}
}

function releaseElement(obj) {
if (selectedObj) {
selectedObj = null;
}
}

//-->
</SCRIPT>


So this how I set it to work= Load onload then go find the JS with pics written doc etc to show if IE4+ in a non window, just pics in the JS file but if the browser doesnt support it, will show the pics in a the size set window.

what I cant seem to work out is how to make that script work on a click.

Help Please

Reply With Quote
  #2  
Old April 24th, 2001, 10:19 AM
pieux pieux is offline
Seņor Member
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2000
Posts: 1,157 pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 h 23 m 35 sec
Reputation Power: 36
What happens when you put exactly what you put in the onLoad inside an onClick?
__________________
Michael

Reply With Quote
  #3  
Old April 24th, 2001, 12:04 PM
GRaPHiX_FReaK GRaPHiX_FReaK is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Nottingham - England (UK)
Posts: 9 GRaPHiX_FReaK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to GRaPHiX_FReaK
Well ive tried that therory I think, If you mean by -

<a href="file.html" onclick="showHTMLPopup()">Click to open popup</a> No go with that, is that what you meant?

Reply With Quote
  #4  
Old April 24th, 2001, 03:05 PM
pieux pieux is offline
Seņor Member
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2000
Posts: 1,157 pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 h 23 m 35 sec
Reputation Power: 36
Yes, that's what I meant, but more like: <a href="javascript:void(0)" onclick="showHTMLPopup()">. Even if it doesn't work, what does happen?

Reply With Quote
  #5  
Old April 24th, 2001, 04:01 PM
GRaPHiX_FReaK GRaPHiX_FReaK is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Nottingham - England (UK)
Posts: 9 GRaPHiX_FReaK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to GRaPHiX_FReaK
Okay, that didnt work dude.

This is what happend -

as I clicked it opened a new window (Cannot be displayed) but the right size, but not the DHTML window, just an ordanary window. Hmmm...then also the main window opened the onclick command (cannot be displayed)

Hmmm....Have you got ICQ? I need to explain and show you the script, its no ordanary script as a normal pop up window, so its hard to explain on here.

Reply With Quote
  #6  
Old April 24th, 2001, 06:13 PM
adios adios is offline
Senior Citizen
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2001
Location: leftcoast
Posts: 2,019 adios User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
GF: any of these will work -

<a href="#" onclick="showHTMLPopup();return false;">Click to open popup</a>

or

<a href="javascript:showHTMLPopup()">Click to open popup</a>

or

<a href="javascript:void(0)" onclick="showHTMLPopup()">Click to open popup</a>


This last is Michael's; for some reason, this editor is parsing the "java" portion of "javascript" and adding a space. I corrected it with a hack I've been using to post character entities (like &nbsp;) - escape the ampersand with &amp; to "fool" the parser (here it's a "j" - j). Someone fix this!!!


If you don't return false from an onclick, the browser will proceed with the default action - loading the HREF into the main window.

Always return your popup to a global variable for further scripting....

Reply With Quote
  #7  
Old April 24th, 2001, 06:37 PM
GRaPHiX_FReaK GRaPHiX_FReaK is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Nottingham - England (UK)
Posts: 9 GRaPHiX_FReaK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to GRaPHiX_FReaK
See that works BUT it pops up in a window, Not as the DHTML window.

Okay, Ive found a example of use http://www.kitkat.co.uk See that Pop Up?

Thats what I mean, see in IE 4 + you can drag it and close it, without the window around it! But in NS 5 - its a normal window with the pics.

Understand now? and how can I make that script DHTML pop up work like a HTML pop up?

Reply With Quote
  #8  
Old April 24th, 2001, 07:07 PM
pieux pieux is offline
Seņor Member
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2000
Posts: 1,157 pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 h 23 m 35 sec
Reputation Power: 36
Talking Nice example!

OK, first of all, stop referring to it as a window. Although it has the appearance of a window, it's a <div>. They are hiding the code from you in a .js file (see http://www.kitkat.co.uk/orangechunky_div.js). The ability to move the <div> dynamically is provided in part by the grabElement() function they are using. Ignore any code that has the word window in it -- it's probably not related.

Reply With Quote
  #9  
Old April 24th, 2001, 07:29 PM
GRaPHiX_FReaK GRaPHiX_FReaK is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Nottingham - England (UK)
Posts: 9 GRaPHiX_FReaK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to GRaPHiX_FReaK
Yeh, I know its a Div layer dude, just that its getting late over here in England, bit tired.

Hmmm....the script isnt in the .js file thats the writen images, to appear for the DIV. Thats what you seem to keep ignoring lol

So can you help me?

Reply With Quote
  #10  
Old April 25th, 2001, 12:11 AM
pieux pieux is offline
Seņor Member
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Aug 2000
Posts: 1,157 pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level)pieux User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 h 23 m 35 sec
Reputation Power: 36
Boy, it must late over there -- it's late over here. There's no such think as Netscape 5, so I'm assuming you mean 6.

What they are probably doing is providing the cool-looking functionality for one browser and a substitue for the one(s) that don't support the code they are using. They have built several functions to handle different tasks and are using them in an object oriented sort of way.

If you look at the code, each one is commented pretty well, indicating what each one does. The reason I pointed out the .js file was to show you parts of their code you may be overlooking.

If you are getting only the window and you are using a browser that should support the DHTML version, chances are you aren't calling the correct function or the browser/object detection/logic is reversed or broken.

Have you tried several different browsers? Does it happen identically on all of them? The onClick code I provided isn't going to adversely affect any of the other code. The only thing onClick provides is a method of triggering the respective function(s). For all it cares, you can do it as a mouseOver, or in an href, or even in a <script> at the bottom of the page.

Reply With Quote
  #11  
Old April 25th, 2001, 08:35 AM
GRaPHiX_FReaK GRaPHiX_FReaK is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Nottingham - England (UK)
Posts: 9 GRaPHiX_FReaK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to GRaPHiX_FReaK
It cant, and wont work like that, I was thinking as Iam not such a scripter, If you can interigate that DHTML script into one .JS file and then maybe use it as a ordanary HTMLPop Up window, which you could, but would take some time and effort to get the output.

so do you reckon that it could maybe able script that?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > DHTML Designed Pop Up !

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap