denn0n Posted September 5, 2014 Share Posted September 5, 2014 Hi everyone. I'm having a problem, this it will be an example about what I'm trying to do the principal document is index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <title>My Website</title> <script type='text/javascript' src='js1.js'></script> </head> <html> <object type="text/php" data="contents.php" border="0"></object> </html> js1.js function myfunction() { document.getElementById("logo").style.backgroundImage="url(background.png)"; } contents.php <script type='text/javascript' src='js2.js'></script> <html> <table onclick="myfunction2()">…</table> </html> js2.js function myfunction2() { myfunction() } what I'm trying to do is the function 2 from the file js2.js calls the function on js1.js i read about some time ago but honestly evean i dont remember it is possible or not, it have to ? it have to be whit DOM i dont understand really good this someone can help me any advise or guide it will be apreciate Link to comment Share on other sites More sharing options...
Ingolme Posted September 5, 2014 Share Posted September 5, 2014 Don't use the <object> element to load a page. You can use <iframe>, or even better you could include the important part using PHP's include. Your HTML is not correct, you should read the HTML tutorial to discover and fix all the mistakes in your code. Link to comment Share on other sites More sharing options...
denn0n Posted September 8, 2014 Author Share Posted September 8, 2014 Don't use the <object> element to load a page. You can use <iframe>, or even better you could include the important part using PHP's include. Your HTML is not correct, you should read the HTML tutorial to discover and fix all the mistakes in your code. that's irrelevant, how dare you say no use object tags? and use iframes !! the problem it is really simple , i need an a function on the file called from the object or iframe tag could call an a other function on the fathers document and the opposite ways to, I apretiate your intention Foxy but i will appretiate more if you help me to get this i need Link to comment Share on other sites More sharing options...
Ingolme Posted September 8, 2014 Share Posted September 8, 2014 A page with invalid HTML is likely to be the cause for many CSS and Javascript problems. I'm not entirely sure the <object> tag will even work in all browsers. text/php is not a standard MIME type. When using an <iframe>, functions from the parent document can be called from the inner document using the window's parent property. Link to comment Share on other sites More sharing options...
Elizabeth_Keen Posted September 8, 2014 Share Posted September 8, 2014 (edited) Your init function is contained by the scope of the function you've passed to jQuery.ready. This is a good thing, it means you haven't created an unnecessary global. If you need to export the function to the global scope, you can do so by explicitly assigning to a property on window, e.g.: window.init = init; Since window is the global object on browsers, that would allow you to call it from Chrome's console without the window. prefix. But only do that if absolutely necessary, the global scope is already crowded enough Function declarations, like your function init() {}, are restricted to the scope they're defined in. If you want to use init elsewhere, do this: var init;$('document').ready(function() {init = function() {};}); Edited September 8, 2014 by Ingolme Advertising 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now