Forum Home
Press F1
 
Thread ID: 140147 2015-08-25 04:23:00 Defining constants in HTML lmohanarun (17390) Press F1
Post ID Timestamp Content User
1407392 2015-08-25 04:23:00 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.

-
lmohanarun (17390)
1407393 2015-08-25 05:16:00 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?
Webdevguy (17166)
1407394 2015-08-25 06:00:00 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
Kame (312)
1407395 2015-08-25 06:58:00 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. pcuser42 (130)
1407396 2015-08-25 07:06:00 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.
chiefnz (545)
1