Solved

How to source value in javascript?

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now