[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to load function at another location

Posted on 2014-08-21
11
Medium Priority
?
105 Views
Last Modified: 2014-08-21
Hi

I have this page:
domain/admin/welcome.html

welcome.html is a frameset and i want to load a function in frame ID "Topmenu".

How is this possible from domain/product.html?

Something like javascript:'/amin/#topmenu.topmenufunction()' ?
0
Comment
Question by:bongii
  • 6
  • 5
11 Comments
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40275720
Something like this should work:
document.getElementById("Topmenu").contentWindow.topmenufunction();

Open in new window

0
 

Author Comment

by:bongii
ID: 40275728
But i am an other document.

I still need to tell the script that it need to look at /admin/welcome.html for the ID.

I want to run the script from /product.html
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40275744
But I thought the other document was also being shown inside an iFrame on the product.html.
No?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bongii
ID: 40275767
More simple:

Popup.html:
function test()
{alert("TEST"}

welcome.html
I want to open popup.html in a popup and call test().

Have tried from welcome.html:
someWin = window.open('popup.html', 'someWin','width=600, height=600,scrollbars=1');
someWin.test();

But it dosen´t call the function
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40275793
For that it's easier because you can just use a CSS based popup like jQuery dialog or something.
In this case the popup is actually part of the page making the function automatically available.
http://jqueryui.com/dialog/

Now, a small side comment:
You shouldn't be embedding javascript in your HTML files.
If instead you put your javascript in js files you can just include and use them without any issues.
This also improves performance because js files are cached by the browsers.
0
 

Author Comment

by:bongii
ID: 40275795
Hi.

Hm it dosen´t answer my question.
I want to open popup.html and call the function test on popup.html.

It´s a closed cms system, so thats why this circus :)
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 2000 total points
ID: 40275807
Ok here's an example using the jQuery dialog I metioned:
http://plnkr.co/edit/6YM6CpWhWuSUYH50QQFs

I'm using plunker because here I can actually have separated files and clearly replicate your scenario.

Attached is the zip file containing the demo
plunk-6YM6CpWhWuSUYH50QQFs.zip
0
 

Author Comment

by:bongii
ID: 40275871
It dosen´t work, but thank you anyway
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40276030
What doesn't work?
It's this solution that doesn't work for you? What's wrong?

We can find something else! :)
This is usually the straight forward way to do it.
0
 

Author Comment

by:bongii
ID: 40276059
I gave up :(
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40276077
Eh, sleep over it and come back whenever you want :)

Cheers!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question