0

i am using Javascript on my page. there is a problem when i use variable to send parameter to function, when i write complete parameters directly as argument it works good like here

<script type="text/JavaScript">
        var X = new MediaController({ContainerDiv:"player",MediaUrl:"test.flv"}');
</script>

but as i use a temp to put this argument in it, and then use temp as argument function it does not work!

<script type="text/JavaScript">
    var temp;
       temp = '{ContainerDiv:"player",MediaUrl:"test.flv"}';
        var X = new MediaController(temp);
</script>

is there a point i missed?

0

2 Answers 2

4

You are assigning a String to the temp variable, which isn't the same as assigning the corresponding object. Instead of this

temp = '{ContainerDiv:"player",MediaUrl:"test.flv"}';

just do this:

temp = {ContainerDiv:"player",MediaUrl:"test.flv"};

and it should work the same.

Sign up to request clarification or add additional context in comments.

Comments

2

You are passing in a string, not an object.

var temp = {ContainerDiv: "player", MediaUrl: "test.flv"};
var X = new MediaController(temp);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.