TheDusty01

Insert variables into browser

Recommended Posts

Hello,

I got a simple question about the CEF. I'm trying to insert variables into the browser but I can't get it to work.

Here's my code:

var browser = mp.browsers.new("package://test/index.html");
browser.execute(`var playerName = ${mp.players.local.name;}; document.getElementById("name").innerText = playerName;`);

After this gets executed my div only says "undefined". Any ideas why?

 

Edit:

Stupid mistake.. I just forgot to put quotation marks around the variable like

borwser.execute(`var playerName = "${mp.players.local.name}"`);

 

Edited by TheDusty01
Solution

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.