470,810 Members | 880 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Combining Two Scripts


Hello!

I came across two different scripts [mouseover and opening the new pag
in a sized window] that I wanted to combine, and I thought I wa
successful until I discovered a minor glitch.

What was happening was that the page that was linked to came out fine
but the page where the link was was linking out to another page [tryin
to direct to the site in my code].
Here's what my code looks like.
<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-examples.com
1000s of free ready to use scripts, tutorials, forums.
Author: JS-Examples - http://www.js-examples.com/
-->

</head>
<body>
<a href="Value="Open Window
ONCLICK="window.open('http://www.geocities.com/taintedrhapsody/tainted.html'
'Sample', 'width=600,height=600')" onmouseover='switchImages("on")
onmouseout='switchImages("off")'><img name="imagename" src="taintx.gif
border="0"></a>
<script>// This creates an image object.
var preloadedImage1 = new Image();// This tells the web browser t
download this image now (rather than later).
preloadedImage1.src="taint.gif";
// This creates an image object also.
var preloadedImage2 = new Image();// This tells the web browser t
download this image now (rather than later).
preloadedImage2.src="taintx.gif";
function switchImages(_onOff) {
if (_onOff=="on")// This replaces the image in the objec
"preloadedImage" and puts
// a copy into the document image object that was defined up above/
with the "img" tag.
document.imagename.src=preloadedImage1.src;
else
document.imagename.src=preloadedImage2.src;

}
</script>
</body>
</html>
What I want my page to do is:
1. The image that links to my main page have a mouseover effect.
2. Have my main page open in the sized window without error.
3. Have the page with the image NOT link or try to open a differen
site.

If someone could help me, I'd be really grateful

Unregistered
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message34382.htm

Jul 20 '05 #1
3 1325
Unregistered hu kiteb:
Hello!

I came across two different scripts [mouseover and opening the new
page in a sized window] that I wanted to combine, and I thought I was
successful until I discovered a minor glitch.

What was happening was that the page that was linked to came out fine,
but the page where the link was was linking out to another page
[trying to direct to the site in my code].
Here's what my code looks like.
Can you clarify that? A new browser window was opened, but it contained
the same page as the original page? Is that right?
<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-examples.com
1000s of free ready to use scripts, tutorials, forums.
Author: JS-Examples - http://www.js-examples.com/
One point: Ther are often problems when combining two pre-made scripts
on the same page without editing them. Common problems include variables
and functions with the same name. It is better to learn at least enough
to understand how the stuff you c&p works than to just copy it blindly.

Looking at your stuff below, I notice that the line breaking is a
complete mess. I'm not sure if this is a deliberate attempt to make it
hard to read, or if it is accident, or if it i an artifact of the
website you posted from.
</head>
<body>
<a href="Value="Open Window"
Change that to

href=#

Thats still not the ideal solution acording to everyone on this list,
but it should leave you on the same page, and won't necessarily result
in an error. I'm curious. Did the original code for your javascripts say
to put that in the href attribute?
ONCLICK="window.open('http://www.geocities.com/taintedrhapsody/tainted.h
tml', 'Sample', 'width=600,height=600')" onmouseover='switchImages("on")'
onmouseout='switchImages("off")'><img name="imagename"
src="taintx.gif" border="0"></a>


The script tags should appear before any calls to that script appear. At
the point where you have " onmouseover='switchImages("on")' ", the page
does not yet know that a switchImages() function even exists. This would
result in an error in a strict interpretation.

[snip code]

--
Fabian
This post is not associated in any way with forum4designers dot com.
Permission is specifically denied for that website to archive this post
or display it in any way.

Jul 20 '05 #2

I know that the whole script was confusing, but I'm not the greatest a
scripts, and I've only taught myself to tweak minor things in th
scripts. What I do is only out of trial and error so I'm not certai
on the changes I make.

Through your reply, I did manage to fix the problem, so I just wante
to say thanks

Unregistered
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message34382.htm

Jul 20 '05 #3
JRS: In article <bu************@ID-174912.news.uni-berlin.de>, seen in
news:comp.lang.javascript, Fabian <la****@hotmail.com> posted at Mon, 19
Jan 2004 14:49:08 :-

Looking at your stuff below, I notice that the line breaking is a
complete mess. I'm not sure if this is a deliberate attempt to make it
hard to read, or if it is accident, or if it i an artifact of the
website you posted from.


AIUI, it is the website.

It has no business connecting to this Usenet newsgroup, and moreover is
evidently badly designed.

Those who wish to have questions answered in a Usenet newsgroup should
post them to that group using appropriate software.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
For news:borland.*, use their server newsgroups.borland.com ; but first read
Guidelines <URL:http://www.borland.com/newsgroups/guide.html> ff. with care.
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

27 posts views Thread by Mxsmanic | last post: by
2 posts views Thread by Brian | last post: by
reply views Thread by Edge | last post: by
3 posts views Thread by Roger | last post: by
5 posts views Thread by Tristan Miller | last post: by
3 posts views Thread by Mike Gleason jr Couturier | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.