B4J Question [ABMateria] Static HTML + CSS

MichalK73

Well-Known Member
Licensed User
Longtime User
Hello.
On the website I made howto using ABEditor (HTML). However, this is a simple editor and a static HTML page with CSS has been prepared. HTML peacefully the component is reading but where to put CSS to the HTML file.
Any tips?
 

Cableguy

Expert
Licensed User
Longtime User
Search for page.finishedloading and put it just after
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Something like this:

CustomIFrame Custom Componet Class:
B4X:
' Class module
Sub Class_Globals
   Dim ABM As ABMaterial 'ignore
   Dim ABMComp As ABMCustomComponent
   Dim mSrc As String
   Dim mWidth As String
   Dim mHeight As String
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(InternalPage As ABMPage, ID As String, Src As String, Width As String, height As String)
   mSrc = Src
   mWidth = Width
   mHeight = height
   
   Dim CSS As String = $""$
   
   ABMComp.Initialize("ABMComp", Me, InternalPage, ID, CSS)       
End Sub

' runs when an object is created for the first time. Expects a valid html string
' will get surrounded by a div automatically
Sub ABMComp_Build(InternalPage As ABMPage, internalID As String) As String
   Dim varID As String = internalID.Replace("-", "_")
   Return $"<iframe id="${varID}" src="${mSrc}" width="${mWidth}" height="${mHeight}" frameborder="0"></iframe>"$
End Sub

' Is useful to run some initalisation script.
Sub ABMComp_FirstRun(InternalPage As ABMPage, internalID As String)
   Dim varID As String = internalID.Replace("-", "_")
   'Dim script As String = $""$
   
   'InternalPage.ws.Eval(script, Array As Object(ABMComp.ID))
   
   'flush not needed, it's done in the refresh method in the lib
End Sub

' runs when a refresh is called
Sub ABMComp_Refresh(InternalPage As ABMPage, internalID As String)
   Dim varID As String = internalID.Replace("-", "_")
End Sub

' do the stuff needed when the object is removed
Sub ABMComp_CleanUp(InternalPage As ABMPage, internalID As String)
   Dim varID As String = internalID.Replace("-", "_")
End Sub

Usage:
B4X:
Dim iFrame As CustomIFrame
iFrame.Initialize(page, "iFrame", "../AboutPage/abmaterial-about.html", "100%", "300px")
page.Cell(14,1).AddComponent(iFrame.ABMComp)
   
page.Refresh ' IMPORTANT
...

All your CSS must be added to your src document. An iFrame is unaware of its parents CSS.

Alwaysbusy
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
you are great !
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
How can i change iFrame's in the runtime ?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…