What is HtmlService?

I was looking through some code when I found this:

HM = Instance.new("HtmlService")
HM.Parent = game

local w = game:service("HtmlService"):NewWindow()


w.DocumentComplete:connect(function ()
w:SetBody([==[

<table width="450" height="200" border="2">
<tr>
<td width="490" bgcolor="#000000"><font color="#FFFFFF">&nbsp;
</font><div align="center">
<p><font color="#FFFFFF"><b>TITLE</b></font></p>
<p><font color="#FFFFFF">by CREATOR</font></p>
<br>
<p><font color="#FFFFFF">NEW SUBJECT TITLE</font></p>
<br>
<p><font color="#FFFFFF">TEXT</font></p>
</div>
</td>
</tr>
</table>

]==])
	
w:Show()
end)

w:Navigate()

I cant find any documentation on it.

3 Likes

There is no such thing as HtmlService, I don’t know why there is even this code anyways.

It was made in 2007 so maybe that’s why.

Ya, that is probably it, because some of this API doesn’t work now, like game:service. Roblox’s API has changed a substantial amount since 2007.

The HTML is a language to script websites etc. This script is creating the label, but this script shouldn’t work at the moment because of changes in Roblox API.

So the HtmlService is used to program in external languages other than lua?

Yes, that’s kinda on what Roblox page is made as well as DevForum.

There is a programming language called HTML which is used to build websites. This is what HtmlService is referencing.

That’s cool, I wish that it was still around now so that i can code in two different languages.

HTML and CSS are not programming languages. They are used for formatting web documents.

7 Likes

Let’s not stray off-topic, shall we?

It could have been possibly used for creating new window instances in Roblox 2007 (like clicking the Buy Robux button on the PromptPurchase gui).

I found some information on HtmlService.
image

11 Likes

I still wish it existed now because it would come useful for opening webpages in games and plugins.

2 Likes

Maybe you should add a solution now.

1 Like

Yeah, I know, right? We could make a working web browser with this using HttpService to fetch the HTML of the page, and use HtmlService to display it. But, there are some vulnerabilities, so I can understand why Roblox disabled it. For example, you could use a tracking pixel or a “web bug” in the page to potentially get a user’s IP address and their device info. However, this could be avoided by loading all external content on the page with a proxy. Plus, you usually can’t do much with an IP address. Typically, you can’t see a user’s personal information through an IP address, unless their WHOIS data is visible, which most ISPs hide. You could also potentially display inappropriate or suggestive images, but you can also do this right now by rendering each pixel as a frame inside of a GUI. So theoretically, if Roblox enabled HtmlService, it wouldn’t really pose that much of a threat to their users.

2 Likes

If you read a sentence in the image(down below), it basically was like a ScreenGui in a way, as users used HtmlService for shop windows and such. So to emulate it, you could HttpService and display the returned results as a GUI.

image

2 Likes

Yes, but it would be both hard and inefficient to convert HTML objects into Roblox GUI objects. For example, in Roblox, if you were to convert a simple 250x250 static image on a page to a viewable image by converting every pixel to a frame, you would need to render 62,500 objects! An example of this is CloneTrooper1019’s PNG Loader. Since it is rendering the image in 3-D with a heightmap, it needs to render a part for every pixel, since there isn’t a more efficient way of doing it. If you were to render it in 2-D, you would need a frame for every pixel. The HtmlService option would be way more efficient, as standard web browsers can render images very efficiently on the GPU, not by rendering every pixel as a frame like we have to do currently in Roblox. I guess you could potentially save rendering costs by using UIGradients, but that is hacky and still inefficient. Also, Roblox currently has no support for external fonts, it can’t render SVGs, et cetera. Having an HTML integration in GUIs, like an HtmlFrame object, would be nice.

2 Likes

I am now trying to make a HTML parser which can be used as a web browser.

3 Likes

If it helps you can try to build off of my parser that I abandoned a year and a half ago:

html.rbxl (26.7 KB)

3 Likes