html link for mouse hover - html

I'm looking for something similar to the a html a tag title text but I want the text to come from a separate file.
For example
whatever

IF you do not have access to server side scripting, then you can have your javascript make an ajax request to the file. Javascritp can open files, but they have to be server readable.

Javascript cannot read from file.
But anyway that is not what you want. You most probably want the text to come from a file in the server, rather than a file from the client machine.
You need server side technologies (PHP, ASP, JSP/java...) for this.
UPDATE:
Ok. You don't have server side technologies. So this is not directly possible. But, first: how are yout HTML pages generated? Hand-coded or generated by some system (a CMS, for instance)?
If you are hand coding your HTML, you need the content of the "title" dynamically (from a file), then this is not possible. HTML or related technologies cannot "directly" read a file, and definitely not a file on the server.
If your HTML is generated by some sort of a generator, then possibly you can integrate this with that system itself.
I absolutely have no idea about the requirements, but is it possible to generate the HTML file based on your "configuration" file with the text everytime the text file changes.
BTW, how complex is your HTML?

Related

VSCode HTML "pieces"

I use "pieces" to avoid confusion with the built-in "snippets" functionality.
The scenario is that I am rendering pages server-side in Nodejs, and as part of that I want to code portions of html in files that can be used to assemble an entire page. These are project-specific so the snippets functionality is really not useful here. Problem is if I write an html file that for example only has a section, VSCode tells me there is an error since that file does not start with <DOCTYPE>, etc.
The goal here is reusable pieces instead of duplicating for each page. E.g. define a header.html file that only defines the <header> section, and can then be inserted into each rendered page.
Has anyone done similar? How to tell VSCode to treat as HTML but without demanding a complete document and indicating an error?

HTML reference an image using extension only without using explicit image file name

I have a question about referencing image in HTML. I have a single snippet of HTML code as
below, where I need to reference an image in a folder called static. The image has an extension of SVG
but it's name is dynamically created. If there a way for HTML to refer to this image by only referring to the file extension? The code below using a wild card doesn't work.
<p>
<img src="/static/*.svg" width="1000">
</p>
Additionally, can we add a logic in HTML such that if there is no SVG file in static folder, we don't render it; if there is one, then render it.
Thank you.
I don't think it's possible to do what you're asking with just HTML. However you can easily do this by adding an id to the tag and applying the attribute based on your condition. There are plenty of examples on the web on how to do this including one already answered here: Javascript set img src
This is possible with a server that is designed for this purpose. There is not a feature of just html that will do this, however. If you don't control the server on the backend, you probably can't get this to work, as it most likely will require custom backend code.
On the backend, you make a simple static html server that will match file patterns, and determine and serve the best match. You can do this any number of ways, and if you look up "how to make a static http server" for your favorite backend language, you likely will find an example to get you started, like these:
https://www.digitalocean.com/community/tutorials/how-to-create-a-web-server-in-node-js-with-the-http-module
https://blog.appsignal.com/2016/11/23/ruby-magic-building-a-30-line-http-server-in-ruby.html
https://stackabuse.com/serving-files-with-pythons-simplehttpserver-module/
You would then have to modify whatever base example you chose with your custom pattern matching code. Your server could be designed to do whatever you wanted with the request you send it, including the scenario you described.
This works because an img tag like the one in your example causes the browser to make a GET http request to your server, passing on the url in the src attribute. So, if you control that server, you can have it respond in any way you want, including treating specific characters like * specially.

How could I find out *which file* a line of text on a webpage is from?

I'm using Chrome's Web Developer extension, but there is this block of text I'd like to edit, which I am obviously able to do in the browser. But as parts of an app of mine was outsourced, I'm unable to find out exactly which file (html or php) contains the block of text.
You're better off using a tool like Agent Randsack to find the block of text in the source code. Once it's in the browser, there's no telling what block of server-side code actually contains it. It might even be coming out of a database.
Unfortunately you can't. You'll have to grep the webserver for the html or php code that contains the text. The webserver generates the html for you from the source files, so from the client perspective there's no way to figure this out unless you somehow add debug info from the server side.

how display html as plain text without modifying the .html

I teach GUI and use web pages rather than PP.
I am starting to add HTML5 and CSS instruction to the course.
for a file style_by_kind.html
CSS example style_by_kind.html
when student clicks on the link, obviously, runs the file and displays.
the students can use "save as" in their browser to get a copy for themselves.
I want to display the source as text so I can lecture about the html CSS code.
The link runs the code.
Physically including the file runs the html code.
does not applicable, output only
does not display, comment
Because of continuous updates, it is undesirable to copy the
file with another file type extension, and impossible to "quote" out the html.
Any easy syntax to put in the link or around a physically included copy,
so the student just sees plain text, would be greatly appreciated.
I would suggest changing the extension of the html file to txt.
So when u browse to the txt file, it will still get displayed in the browser with the exact same coding.
Depending on how the files are served up, you might be able to set a ContentType header as text/plain, but I suspect most browsers will still sniff the MIMETYPE of the file and render it as html.
Using the <pre> tag as #hamlin11 suggests is a good idea.
Use <plaintext></plaintext> tags
For example, "This is a lesson on bold tags: <plaintext><b>Bold Text</b></plaintext> will display as <b>Bold Text</b>"

PdfSharp, GDI+ and HTML printing

I currently have a "PrintingWebService" that I call from an AJAX page with all the information that is needed to construct a highly customized PDF printout using PDF Sharp and the PDFSharp's GDI+ mode, which takes DrawString and other commands that work basically just like GDI+ only they are drawn to the PDF.
I then save the PDF file to a location on the webserver and return the file name from the web service, and the AJAX page opens a new window with the pdf file.
So far, it works well, however, there is one part of my AJAX page that I want to printout and I haven't come up with a solution for yet. I've got a string of the HTML content of a TinyMCE editor that I want to dispay in the bottom part of the PDF page.
I'm looking for some sort of tool I could use for this purpose. Even something opensource that prints to GDI+ I could use by taking the source code and translating it to use PdfSharp's GDI+ (the class names are like XGraphics, with each class having X before the GDI+ name).
If I have to I will limit what HTML can be generated by TinyMCE and write my own renderer, but that will be a big challenge, so I'm looking for other solutions first.
I've stayed away from a printer-friendly page approach because I wanted to construct a page that was a near identical of an existing WinForms printout, using my existing code. With PdfSharp I was able to convert all the code except the text area stuff (which used the RichTextBox and RTF in the WinForms version).
Tony,
I personally have used WebSupergoo's ABCPdf library with much success. You can actually render HTML directly to the PDF and it does fairly well in regards to accuracy.
Another free software that will allow you the flexibility of writing HTML to PDF that I have used in the past with much success is iTextSharp.
Otherwise, I think you'll have to write something to render HTML to GDI.
Either way, you may want to consider using an HttpHandler that you map to using your web.config to generate the PDF file. This will allow for you to render the PDF to a bytestream and then dump it directly to the user (as opposed to having to save each PDF receipt to the web server). It will also allow for you to use the .pdf extension in the page that returns the receipt (PurchaseReceipt.pdf could be mapped to a HttpHandler)... making it more cross-browser friendly. Older versions of Adobe / Browsers will not display correctly if you start throwing a PDF byte stream from an ASPX page.
Hope this helps.