469,927 Members | 1,978 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Use javascript function from other .html file

Helo!

I have a little problem.
My whole page (index.html) is based on one big table and an iFrame. In
this iFrame one of the pages is a picture-thumbnail page. I found a
javascript to open thumbnailed pictures in a really nice new window
(it's not really a window but an iFrame, that can be moved around).
The problem i am facing is that this window that opens picture is
limited to the size of the index.html iFrame. If a picture is bigger
it stays hidden in the index.html iFrame. The solution i thought of
was that i would put the open thumbnail window script in the
index.html file and call the function from the picture-thumbnail
iFrame file so that it would open in index.html not inside the iFrame.
However so far i haven't been able to find a way to call javascript
functions from other html files. If anyone has any ideas how to solve
this please help....

thnx, lp john
Jul 20 '05 #1
5 2035
In article <55**************************@posting.google.com >,
lo********@volja.net (lordslayer) writes:
However so far i haven't been able to find a way to call javascript
functions from other html files. If anyone has any ideas how to solve
this please help....


parent.frames.myFunctionName()

In the IFrame page will call myFunctionName() in the main page. Except in
Opera, I didn't play around with it enough to find a way there.
--
Randy
Jul 20 '05 #2
Does by any chance this work only for Mozilla? Because i tried it in
IE and it didn't work... Any ideas why..?

lp John
Jul 20 '05 #3
In article <55**************************@posting.google.com >,
lo********@volja.net (lordslayer) writes:
Does by any chance this work only for Mozilla? Because i tried it in
IE and it didn't work... Any ideas why..?


What didn't work? It is advisable to quote what you are replying to so that
people that read it will be able to follow the conversation.

blank.html:

<script type="text/javascript">
function myFunctionName(){
alert('It works')
}

<iframe src="blank2.html"></iframe>

And in blank2.html:

<a href="#" onclick="parent.frames.myFunctionName();return false">Test</a>

IE6.0: alert message
Mozilla1.5: alert message
Netscape7.1: alert message

If what you are doing isn't working in Mozilla, then you are doing something
more than what my test page uses to show that it works. Post a URL to a test
page......

And read the FAQ - http://www.jibbering.com/faq/
--
Randy
Jul 20 '05 #4
hi************@aol.com (HikksNotAtHome) wrote in message news:<20***************************@mb-m01.aol.com>...
In article <55**************************@posting.google.com >,
lo********@volja.net (lordslayer) writes:
Does by any chance this work only for Mozilla? Because i tried it in
IE and it didn't work... Any ideas why..?


What didn't work? It is advisable to quote what you are replying to so that
people that read it will be able to follow the conversation.

blank.html:

<script type="text/javascript">
function myFunctionName(){
alert('It works')
}

<iframe src="blank2.html"></iframe>

And in blank2.html:

<a href="#" onclick="parent.frames.myFunctionName();return false">Test</a>

IE6.0: alert message
Mozilla1.5: alert message
Netscape7.1: alert message

If what you are doing isn't working in Mozilla, then you are doing something
more than what my test page uses to show that it works. Post a URL to a test
page......

And read the FAQ - http://www.jibbering.com/faq/

Helo!

I tried what you suggested and it still works only in Mozilla.
I put my page online at
http://users.volja.net/lordslayer/page/index.html

If you click on "photo" link, there is a thumbnail that opens full
picture correctly only if you use Mozilla .. IE doesn't open it right
.... it still opens it in the iFrame.

"Index.html" contains the javascript. "Foto.html" contains the link to
the javascript in index.html

Maybe if you see it you might better understand my problem... I thank
you again for your help.

lp john
Jul 20 '05 #5
lo********@volja.net (lordslayer) wrote in message news:<55**************************@posting.google. com>...
hi************@aol.com (HikksNotAtHome) wrote in message news:<20***************************@mb-m01.aol.com>...
In article <55**************************@posting.google.com >,
lo********@volja.net (lordslayer) writes:
Does by any chance this work only for Mozilla? Because i tried it in
IE and it didn't work... Any ideas why..?


What didn't work? It is advisable to quote what you are replying to so that
people that read it will be able to follow the conversation.

blank.html:

<script type="text/javascript">
function myFunctionName(){
alert('It works')
}

<iframe src="blank2.html"></iframe>

And in blank2.html:

<a href="#" onclick="parent.frames.myFunctionName();return false">Test</a>

IE6.0: alert message
Mozilla1.5: alert message
Netscape7.1: alert message

If what you are doing isn't working in Mozilla, then you are doing something
more than what my test page uses to show that it works. Post a URL to a test
page......

And read the FAQ - http://www.jibbering.com/faq/

Helo!

I tried what you suggested and it still works only in Mozilla.
I put my page online at
http://users.volja.net/lordslayer/page/index.html

If you click on "photo" link, there is a thumbnail that opens full
picture correctly only if you use Mozilla .. IE doesn't open it right
... it still opens it in the iFrame.

"Index.html" contains the javascript. "Foto.html" contains the link to
the javascript in index.html

Maybe if you see it you might better understand my problem... I thank
you again for your help.

lp john


Success!!! I've made this damn thing work... It wasn't your
suggestion's fault it was my damn javascript. I located and removed
the mistake so it works great now... Thanx again for the advice about
the function call....

lp john
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.