Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to insert variables in the html source #31

Open
superuser7777 opened this issue Apr 11, 2023 · 1 comment
Open

How to insert variables in the html source #31

superuser7777 opened this issue Apr 11, 2023 · 1 comment

Comments

@superuser7777
Copy link

superuser7777 commented Apr 11, 2023

Neutron.ahk is a revolution in AHK GUI, thanks for a great library!
I look forward to the implementation of WebView2!
I am reading the documentation and samples and trying to figure it out through trial and error.

The code below didn't work.

How should I write the code?
Or is there another better way?

*ahk

image_path := "D:\image.jpg"
neutron := new NeutronWindow(html,css,js,title)
neutron.Load("test.html")
neutron.Gui("+LabelNeutron +AlwaysOnTop +border +ToolWindow -Resize")
neutron.Show("w300 h300")

neutron.qs(".span").innerHTML := "<img src=`""%image_path%"`">" "</img>"   ;<--- Variables are printed as strings.
MsgBox, % neutron.doc.body.outerHTML
ExitApp

*html

<body>
<head>
<style>
span {
	width: 100%;
	height: 100%;
}
</style>
</head>
<div>
<span class="span"></span>   ;<--- Insert img tag
</div>
</body>
@superuser7777
Copy link
Author

I self-solved.

*ahk

imgItem := neutron.doc.createElement("img")
imgItem.src := image_path
neutron.qs(".span").appendChild(imgItem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant