Comments (7)
@fingers10 You can use this method as well.
var module = await JS.InvokeAsync<IJSObjectReference>("import", "/lib/xxx.js");
await module.InvokeVoidAsync(xxx);
from toolbelt.blazor.headelement.
Hi @Alerinos , Thank you for helping us!
By the way, I guess that @fingers10 is talking about his website "https://ilovedotnet.org/" (The source code is here). And that website is hosted on GitHub Pages. The website is a Blazor WebAssembly app without ASP.NET Core hosting, so he might not be able to take a server-side strategy such as you suggested.
Hi @fingers10,
@Alerinos do you mean MainLayout.razor in blazor wasm?
I think the answer is no, and he may not want to mean that.
I guess the "_Layout" that he told us is an ASP.NET Core Razor Pages that run on server-side .NET processes. It is contained in Blazor Server or ASP.NET Core Host for Blazor WebAssembly.
from toolbelt.blazor.headelement.
I understand, in that case you have to write JS code and then execute it in blazor.
Example:
JS.InvokeVoidc("loadJS", "url.js")
from toolbelt.blazor.headelement.
@fingers10 Actually, injecting <script>
elements dynamically is a more complicated task than you might think.
Instead, would the following package help you?
from toolbelt.blazor.headelement.
@fingers10 You can use this method as well.
var module = await JS.InvokeAsync<IJSObjectReference>("import", "/lib/xxx.js"); await module.InvokeVoidAsync(xxx);
@Alerinos does this approach adds the script
tag to head element? I would like to just add an script tag with src
pointing to cdn conditionally..
from toolbelt.blazor.headelement.
@fingers10 Why can't you do this in _Layout?
from toolbelt.blazor.headelement.
@fingers10 Why can't you do this in _Layout?
@Alerinos do you mean MainLayout.razor
in blazor wasm?
from toolbelt.blazor.headelement.
Related Issues (20)
- Link support and title constant HOT 1
- After update to 6.0.0 the tab text will not automatically update HOT 1
- Add Meta Element without overwriting the existing one HOT 1
- Can only include one HrefLang tag (cannot implement recommended pattern) HOT 5
- Could not find 'Toolbelt.Head.Title.query' ('Toolbelt' was undefined) but on Blazor WASM and DisableClientScriptAutoInjection = true HOT 4
- Should I reapply <Meta> tags on each page of the app? HOT 1
- System.ObjectDisposedException showing up in Production Logs HOT 2
- [Feature Request] Options to supply Type, Hreflang, Title and other options in Link Element
- [Feature Request] Discriminate <Meta> overrides base on other attributes too HOT 5
- [Bug] 7.1.0 - <meta> content attribute value becomes empty and gets replaced by media attribute which gives unexpected results in browser HOT 8
- Changelogs not found HOT 1
- Allowing multiple og:image elements HOT 1
- Consider falling back on setAttribute when HTMLMetaElement.prototype.media doesn't exist HOT 2
- Performance issue HOT 14
- <Link> creates forece reload HOT 4
- Change Html base tag HOT 2
- [Feature Request] HOT 1
- Unhandled exception in circuit HOT 4
- HeadElement depends on Toolbelt.Blazor.HotKeys? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toolbelt.blazor.headelement.