PDA

View Full Version : Defining constants in HTML



lmohanarun
25-08-2015, 04:23 PM
I have a phone number that occurs in
atleast two different parts of the same web page
(HTML)

Same phone number occurs in other pages
of same (website)

Other than using a server-side scriptable
language I want to use Basic HTML.

Is this possible with HTML, I know it is
possible with framework.

-

Webdevguy
25-08-2015, 05:16 PM
I have a phone number that occurs in
atleast two different parts of the same web page
(HTML)

Same phone number occurs in other pages
of same (website)

Other than using a server-side scriptable
language I want to use Basic HTML.

Is this possible with HTML, I know it is
possible with framework.

-

HTML is purely static code so you can have the phone number displayed multiple times on multiple pages. You just need to copy and paste the code from the first instance to all the other places where you want it displayed.
Is that what you wanted to know?

Kame
25-08-2015, 06:00 PM
You can use client side scripting (javascript) to insert it, but it relies on the document being fully loaded to ensure the place it is inserted into exists.

This means you could create an external JS file that can be included in your pages and insert the phone number.

Another method, could be using CSS to insert the text, using a before or after content style to a specific element.

Out of these options, I really wouldn't know my preferred method as both are quite easy for updating but CSS would probably be a more confusing method for someone else to work on.

Cheers,

KK

pcuser42
25-08-2015, 06:58 PM
The ideal way to do this is to use a server side scripting language (like PHP) to insert the constant. As Kame said it can be dome with CSS (with :before and :after pseudoclasses) but it's a bit of a hack.

chiefnz
25-08-2015, 07:06 PM
Yeah would have to agree on this one... HTML isn't really a "programming" language per say... it doesn't work on the premise of making "calls" for info. It is by and large a static format.

I'm curious as to why you want to "set a constant" or "call a constant" for a webpage?

What exactly are you trying to achieve apart from ensuring that the correct phone number is used in all instances/occurrences across the web page.