-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with Global Vars and callBackFunction #5
Comments
You should move popup code to /* 1 */ , otherwise it won't work. Uncaught TypeError: Cannot read property 'document' of undefined |
Hi Suhaib, Actually I tried that, and that is when I get the error Uncaught Type Error. For some reason it does not work in your function code. The pop up code works perfectly where it is but there is no data from the function, but when I add it to the function that's when I get the error... There is nothing wrong with var generator that I can see. I debug using chrome debugger, I don't know firebug. Regards, |
OK I've done some more testing...as follows test 1
test 2 While I'm a relative noobie to javascript and do not understand it all, I cannot figure out why it will not work It would be so mach easier (for me) if it was as easy as (1)...
currently the code is(2):
But this fails making the routine basically useless as the data is stuck inside the function and cannot be used outside. So two questions:
I have read that
can fail with the above error if popups are disabled...(I have popups enabled)... ####BUT#### this code works...
and this doesn't
); Why does the function code not work when the previous one does? It's obvious that popups are working as seen in the previous example... I believe this is an excellent tool and would be great for popups if it could be used...but at the moment it fails...unfortunately. Thanks and regards |
Hi Sean, index.html <html>
<head>
<title>Test Popup</title>
</head>
<body>
<input type="button" value="Show Popup" onclick="showPopup()" />
<script src="messageResource.js"></script>
<script src="main.js"></script>
</body>
</html> main.js var firstValue, secondValue;
function showPopup(){
messageResource.init({
debugMode : true
});
messageResource.load('test', function(){
firstValue = messageResource.get('first', 'test');
secondValue = messageResource.get('second', 'test');
var generator = window.open('', 'Popup Window', 'height=700,width=500');
generator.document.write('<html><head><title>Popup</title>');
generator.document.write('</head><body>');
generator.document.write('<p>' + firstValue + '</p>');
generator.document.write('<p>' + secondValue + '</p>');
generator.document.write('</body></html>');
generator.document.close();
});
} I tested the above code and its working for me, also i didn't get any error while opening a popup inside callback. |
Hi there,
I've got your service working nicely except...it won't do what I want it too...
my code is simple enough and is shown below:
Summary
Global Vars
messageResource.init
messageResource.load //get two messages into global vars
open a popup using global vars
The code works and the messages are loaded in messageResource.load and can be seen in console.log
BUT when i try to use the global vars in the popup they are empty!!! So why is this happening?
Then I thought, OK I will try moving the popup code to /* 1 */
but then I get a message ...
Uncaught TypeError: Cannot read property 'document' of undefined
How can I use your routine to accomplish what I want, it seems ideal but...
I've also move the callBackFunction from inline to where the popup code is but I don't understand these things.
I assume this is my problem...but how do I get it too work???
Many thanks and best regards
Seán
The text was updated successfully, but these errors were encountered: