Bind (Method)

Revision as of 18:41, 13 February 2024 by Pongo02 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Bind( Instance object, String property, String htmlElementId )
Returns nil
Description: Binds the property of an instance to an HTML input.
Member of: HtmlWindow


Example
This code will create a Hint, and Bind an input to the Text property. It will give the option to toggle the Bind:
html = game:service("HtmlService")

wind = html:NewWindow()
wind:Navigate()

hint = Instance.new("Hint", game.Workspace)
hint.Name = "BindedHint"

function Call(ValueReturn)
	if ValueReturn == "bind" then
		wind:Bind(hint, "Text", "scriptsrc")
	elseif ValueReturn == "unbind" then
		wind:Unbind()
	end
end

wind.DocumentComplete:connect(function(url)
	wind:SetBody([==[
		<input id="scriptsrc">

		<input type="submit" onclick="window.external.Call('bind');" value="Bind Me!">
		<input type="submit" onclick="window.external.Call('unbind');" value="Unbind Me!">

		<img style="display: none;" src='' onerror="window.external.Call('bind');">
	]==])
end)

wind:SetCallback(Call)
wind:Show()