Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to source value in javascript?

Posted on 2012-04-12
3
Medium Priority
?
201 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 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

636 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