Solved

How to source value in javascript?

Posted on 2012-04-12
3
182 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
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…

738 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