Solved

How to source value in javascript?

Posted on 2012-04-12
3
183 Views
Last Modified: 2012-04-12
If I have something like:

window.gaikai = {
                        emailToken: 'KHn5rB8007' // token
                gameCode: 'my_g_origin',
                messageCallback: function(obj) {
                              var currGame = 'my_g_origin';
                    // Log all messages to browser console, if available
                    if (console && typeof console.log === 'function') {
                        console.log(obj.message);
                    }
                    if (obj.message === 'clickPlayNow') {
                                 var autoPlay =  location.href.indexOf("gaikaiInstantPlay") > 0;
                                 if(autoPlay){currGame = currGame + '_autoPlay';}
                                 setOmniValues('','o','clickPlayNow','','e66='+currGame,'ev91',0,'','')
                       
                    }
                 }
            };

Is there a way I can source the value of gameCode: 'my_g_origin' in the javascript without reassigning it as I'm doing (var currGame = 'my_g_origin';)? Is it window.gaikai.gameCode?


Thanks!
0
Comment
Question by:894359
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Expert Comment

by:basicinstinct
ID: 37840612
Yes but it looks like you missing a comma after this line:

 emailToken: 'KHn5rB8007'

Should be

 emailToken: 'KHn5rB8007',
0
 

Author Comment

by:894359
ID: 37840621
Yeah I caught that! ;0) Thanks! So how do I reference it in my js? None of the below work?

alert(gaikai.gameCode);
alert(gaikai.gameCode.value);
alert(window.gaikai.gameCode);
alert(window.gaikai.gameCode.value);
0
 
LVL 23

Accepted Solution

by:
basicinstinct earned 500 total points
ID: 37840630
This is the right one:
 alert(window.gaikai.gameCode);

If it doesn't work you got a problem somewhere else in your script.

you need to advance beyond alert debugging. press f12 in your browser and start using the console in the developer tools
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

695 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