2

I have built an HTML start page that can be expanded according to your own wishes. The experts among you certainly see a lot of room for improvement. However, I am currently trying to automatically enter the current full version number of the Firefox browser in line 106, where the number 99.0 is currently located. (Linux Mint 19.3 mit Firefox Browser 99.0) I've already spent a lot of time on this, but I can't find a suitable solution. That's why I'm asking you, does anyone have a suitable idea? Here is the code:

<!DOCTYPE html> 
<html lang="de">
<head> 
    <title>Menue</title>
    <meta charset="utf-8" /> 
    <style>
    
    body { background:url(ff3.jpg) fixed; margin:0px; zoom:1.00; -moz-transform:scale(1.00); }
    a:link { text-decoration:none; font-weight:normal; color:#3246ff; }
    a:visited { text-decoration:none; font-weight:normal; color:#800000; }
    a:hover { text-decoration:none; font-size:115%; color:#FFFFFF; background-color:#800000; border-radius: 80px !important; border:none!important; }  
    a:before { content: "»   "; color:#000000; }     

/* grid layout, 3 columns */
.wrapper {
  display: grid; /* display: inline-grid;*/
  grid-template-columns: 1fr 1fr 1fr; /* 3 x 1 fraction */
  align-content:space-center;
  justify-content:center;
  margin-top: 50px;   
}

      :hover {
    animation-play-state: paused;
  }

.scroller {
  width: 30px;
  height: 100px;
  overflow-y: scroll;
  scrollbar-color: rebeccapurple green;
  scrollbar-width: thin;
}

.example1 {
  height: 80px;
  color:#800000;
  overflow: hidden;
  position: relative;
}
.example1 h3 {
    position: absolute;
    width: 120%;
    height: 90%;
    margin: 0;
    line-height: 90px;
    text-align: center;


    /* Starting position */
       -moz-transform:translateX(100%);
       -webkit-transform:translateX(100%);  
       transform:translateX(100%);

 /* Apply animation to this element */  
       -moz-animation: example1 25s linear infinite;
       -webkit-animation: example1 25s linear infinite;
       animation: example1 25s linear infinite;
}

/* Move it (define the animation) */
      @-moz-keyframes example1 {
       0%   { -moz-transform: translateX(100%); }
       100% { -moz-transform: translateX(-100%); }
      }
      @-webkit-keyframes example1 {
       0%   { -webkit-transform: translateX(100%); }
       100% { -webkit-transform: translateX(-100%); }
      }
      @keyframes example1 {
       0%   { 
       -moz-transform: translateX(100%); /* Firefox bug fix */
       -webkit-transform: translateX(100%); /* Firefox bug fix */
       transform: translateX(100%);         
       }
       100% { 
       -moz-transform: translateX(-100%); /* Firefox bug fix */
       -webkit-transform: translateX(-100%); /* Firefox bug fix */
       transform: translateX(-100%); 
       }
      }
    </style>
  </head>
  <body>

<br><br>
<div style="display: table; width: 100%; height: 100px;">
<figure style="display: table-cell; padding: 0 4px; text-align: center;"><img src="pag37.gif"></figure>
<figure style="display: table-cell; padding: 0 4px; text-align: center; vertical-align: middle;"><img src="pag107.gif"></figure>
<figure style="display: table-cell; padding: 0 4px; text-align: center;"><img src="pag37.gif"></figure>
<figure style="display: table-cell; padding: 0 4px; text-align: center; vertical-align: middle;"><img src="pag107.gif"></figure>
<figure style="display: table-cell; padding: 0 4px; text-align: center;"><img src="pag37.gif"></figure>
</div>

<script>
    var fullVersion  = ''+parseFloat(navigator.appVersion);
    var fullVersion = nAgt.substring(verOffset+8);
    var vers = fullVersion
    if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
 browserName = "Firefox";
 fullVersion = nAgt.substring(verOffset+8);
}
  </script>

<div class="example1">
   <h3 style="font-size:22px">+++ Achim's Internetportal - Betriebssystem Linux Mint 19.3 mit Firefox Browser 99.0 in der 64 Bit-Version +++</h3> // Line 106!!!
</div>

</body> 
</html>

<table border="5" cellspacing="5" bordercolor=#990000 height="420px" width="100%">
<tr style="font-family:Verdana; font-style:bold italic; font-size:16px;">
<td width="33%" valign="top">
<ul>
<a HREF="https://www.chip.de/" target="_blank">Chip - Online</a>  Computer-Nachrichten  «<br>
</ul>
</td>
<td width="33%" valign="top">
<ul>
<a HREF="https://www.linuxmintusers.de/" target="_blank">Linuxmintusers</a> Systemunterstützung  «<br>
</ul>
</td>

<td width="33%" valign="top">
<ul>
<a HREF="https://www.tippscout.de/computer/linux" target="_blank">Tippscout</a> praktische Tipps zu Linux  «<br>
</ul>
</td>
</tr>
</table>

1 Answers1

0

Put the div before the script and try this:

<div class="example1">
    <h3 style="font-size:22px">+++ Achim's Internetportal - Betriebssystem Linux Mint 19.3 mit Firefox Browser $(fullVersion) in der 64 Bit-Version +++</h3>
</div>

<script>
    if ((verOffset = navigator.userAgent.indexOf("Firefox")) != -1) {
        var agent = navigator.userAgent;
        var index = agent.indexOf("Firefox/");
        var fullVersion = agent.substr(index + 8)
        var div = document.getElementsByClassName("example1")[0];
        var h3 = div.getElementsByTagName('h3')[0];
        h3.innerText = "+++ Achim's Internetportal - Betriebssystem Linux Mint 19.3 mit Firefox Browser " + fullVersion + " in der 64 Bit-Version +++";            
    }
</script>

You search the example1 div and the h3 that is contained in it. Then, you set the text.

Victor
  • 2,313
  • 2
  • 5
  • 13
  • You're on the right track, but now it says "Firefox Browser 5" instead of 99.0. What else needs to be changed? – scotty030253 Apr 10 '22 at 18:02
  • https://www.seanmcp.com/articles/how-to-get-the-browser-version-in-javascript/ @scotty030253 – Andy Apr 10 '22 at 18:11
  • Sorry, after an update, version "99.0.1" is now installed. However, "99.0" is still displayed. What changes in the code do I need to make? – scotty030253 Apr 19 '22 at 00:29
  • What is the userAgent text now? – Victor Apr 19 '22 at 06:11
  • I think you can't do that (run PowerShell command, acces to Windows Registry...) for security reasons. You may try to develop a FireFox extension to do that – Victor Apr 19 '22 at 09:56
  • I'm running a Linux system (Linux Mint 19.3) with a Firefox browser, no Windows with a registry. My suggestion using bash was just an idea. Isn't it possible to change their suggestion above to show the complete string "99.0.1"? – scotty030253 Apr 19 '22 at 13:17
  • This Linux bash determines the current Firefox version (99.0.1) and writes it to the "version.js" file: destfile=/home/achim/Dokumente/3-ff_startseite/version.js vers=$(firefox --version) versk=${vers:16:7} echo "$versk" > "$destfile" How does Victor's example have to be modified so that the script content is displayed in the HTML? – scotty030253 Apr 19 '22 at 23:31
  • If you have a global var with the version and this script is loaded in your html page, you can use your "versk" variable instead "fullVersion" of my sample – Victor Apr 20 '22 at 07:41
  • I created a global variable "versk" and replaced "fullVersion" with "versk" in your example. The file version.js contains the correct version number "99.0.1". If I now restart the HTML, "99.0" is still displayed there. Unfortunately it doesn't work that way yet. – scotty030253 Apr 20 '22 at 11:50
  • But are you using your versk variable or a local variable in my code? – Victor Apr 20 '22 at 13:54
  • I changed it like this: – scotty030253 Apr 20 '22 at 16:26
  • You have only changed the name of the variable. But that variable is still a local variable, with the value of the userAgent. That is not the variable in your script. If you include the jQuery script, you can use the jQuery variable or the $. If you include your script and your script has a versk variable defined, you can use it directly instead of fullVersion, without declaring it again (without using var). You only need the last 3 lines: var div...; var h3...; h3.innerText = "... Browser" + versk + "in der 64 Bit-..."; – Victor Apr 20 '22 at 21:48
  • Excuse me Victor, jQuery is new to me. I don't understand how to do this. – scotty030253 Apr 20 '22 at 23:18
  • No, jQuery is only a very well known library and I used to show you that you don't need declare versk in my source code, you must use the existing versk of your script. You don't need jQuery to solve this. You told me that you have a script with that variable. You only need load that script in your page to get access to that variable and use in my code, that now don't need access to userAgent: only need use your versk variable. – Victor Apr 20 '22 at 23:25
  • how do i load the bash script on my site, like this: – scotty030253 Apr 20 '22 at 23:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/244065/discussion-between-victor-and-scotty030253). – Victor Apr 20 '22 at 23:50