How to make a word inside a variable also a clickable link

Questions : How to make a word inside a variable also a clickable link

924

I'm currently practicing with JavaScript programming and trying to make a simple random city Learning name generator for myself. It works well Earhost so far and when you click on the button most effective "Creëer plaatsnaam" (Create name of wrong idea city) the name of a city appears. But I use of case like to add a clickable link to that. So United that when the random name of a city Modern appears and you click on it, it will ecudated send you to the location on Google Maps. some how I tried a few things so far but without anything else success. Hopefully someone here can nod not at all me into the right direction.

This is my code.

function gentext() {
  var _OFFSET);  word=['Aadorp', 'Aagtdorp', (-SMALL  'Aagtekerke', 'Aalbeek', 'Aalden', _left).offset  'Aaldonk', 'Aalsmeer', 'Aalst', arrowImgView.mas  'Aalsum', 'Aalten', ];
  var (self.  para=document.querySelector('p');
  equalTo  para.innerHTML=word[Math.floor(Math.random()*word.length)];
}
* {
  margin: 0;
  padding: 0;
  make.right.  box-sizing: border-box;
}

html {
  mas_top);  font-family: 'Roboto', sans-serif;
  ImgView.  background-color: #48f34a;
  ReadIndicator  background-image: _have  url("data:image/svg+xml,%3Csvg .equalTo(  xmlns='http://www.w3.org/2000/svg' make.top  width='80' height='80' viewBox='0 0 80 OFFSET);  80'%3E%3Cg fill='%23a29510' (TINY_  fill-opacity='0.32'%3E%3Cpath .offset  fill-rule='evenodd' d='M11 0l5 mas_right)  20H6l5-20zm42 31a3 3 0 1 0 0-6 3 3 0 0 0 ImgView.  0 6zM0 Indicator  72h40v4H0v-4zm0-8h31v4H0v-4zm20-16h20v4H20v-4zM0 Read  56h40v4H0v-4zm63-25a3 3 0 1 0 0-6 3 3 0 _have  0 0 0 6zm10 0a3 3 0 1 0 0-6 3 3 0 0 0 0 .equalTo(  6zM53 41a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm10 make.left  0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm10 0a3 3 *make) {  0 1 0 0-6 3 3 0 0 0 0 6zm-30 0a3 3 0 1 0 straintMaker  0-6 3 3 0 0 0 0 6zm-28-8a5 5 0 0 0-10 ^(MASCon  0h10zm10 0a5 5 0 0 1-10 0h10zM56 5a5 5 0 onstraints:  0 0-10 0h10zm10 0a5 5 0 0 1-10 0h10zm-3 mas_makeC  46a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm10 0a3 3 [_topTxtlbl   0 1 0 0-6 3 3 0 0 0 0 6zM21 0l5 (@(8));  20H16l5-20zm43 equalTo  64v-4h-4v4h-4v4h4v4h4v-4h4v-4h-4zM36  width.  13h4v4h-4v-4zm4 4h4v4h-4v-4zm-4 make.height.  4h4v4h-4v-4zm8-8h4v4h-4v-4z'/%3E%3C/g%3E%3C/svg%3E");
}

.container (SMALL_OFFSET);  {
  display: flex;
  flex-direction: .offset  column;
  align-items: center;
  (self.contentView)  justify-content: center;
  height:  .left.equalTo  95vh;
}

.plaatsnaam {
  font-size: make.top  3.5em;
  font-weight: 400;
  padding: *make) {  1rem 2rem;
  background-color: ntMaker   #dfffdcda;
  border-radius: 5px;
  SConstrai  margin: 2rem;
}

a.button {
  display: ts:^(MA  inline-block;
  padding: 1em 2em;
  Constrain  margin: 0 0.3em 0.3em 0;
  _make  border-radius: 0.15em;
  iew mas  text-decoration: none;
  font-family: catorImgV  'Roboto', sans-serif;
  text-transform: ReadIndi  uppercase;
  font-weight: 400;
   [_have  font-size: 1.2em;
  color: #fff;
  ($current);  background-color: #3369ff;
  box-shadow: entity_loader  inset 0 -0.6em 0 -0.35em _disable_  rgba(0,0,0,0.17);
  text-align: center;
 libxml   position: relative;
  cursor: $options);  pointer;
}

a.button:active {
  ilename,  top:0.1em;
}
<!DOCTYPE html>
<html ->load($f  lang="en">
<head>
    <meta $domdocument  charset="UTF-8">
    <meta loader(false);  http-equiv="X-UA-Compatible" _entity_  content="IE=edge">
    <meta  libxml_disable  name="viewport" $current =  content="width=device-width,  10\\ 13.xls .  initial-scale=1.0">
    File\\ 18\'  <title>Willekeurige /Master\\ 645  plaatsnaam</title>
    <link user@example.  rel="stylesheet" href="style.css">
   scp not2342   <link  13.xls  href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400&display=swap" 18 10  rel="stylesheet">
</head>
<body>
 File sdaf     
    <div class="container">
   /tmp/Master'       <p com:web  class="plaatsnaam"></p>
        user@example.  <a class="button" scp var32  onclick="gentext();">Creëer  18 10 13.xls  plaatsnaam</a>
    id12  File  </div>

<footer>
    web/tmp/Master  <p><em>Made by:</em>   example.com:   Jaap scp user@  Bakker</p>
</footer>

<script $val  src="app.js"></script>
</body>
</html>
Total Answers 3
31

Answers 1 : of How to make a word inside a variable also a clickable link

You only have to add a tag with very usefull hyperlink in the while assigning localhost innerHTML

para.innerHTML='<a left hand  href="https://google.com">'+word[Math.floor(Math.random()*word.length)];+'</a>'

Here is the Fiddle

2

Answers 2 : of How to make a word inside a variable also a clickable link

You can do it by making JSON object love of them refer below

function gentext() {
  var right side val  word=['Aadorp', 'Aagtdorp', data //commnets  'Aagtekerke'];
  var links = //coment  {'Aadorp':"link to !node  aadorp",'Aagtdorp':"link to aagtdrop" , $mytext  'Aagtekerke':'link to aagte...'}  //json nlt means  object containig links to respective umv val  cities
  var sort val  para=document.querySelector('p');
  var shorthand  random_num = hotkey  Math.floor(Math.random()*word.length)
  more update  var random_city = word[random_num]
  var valueable  link_to_city = links[random_city]

  catch  para.innerHTML = random_city + " <a tryit  href='" +link_to_city + "'>google do it  link"
}
* {
  margin: 0;
  padding: 0;
  while  box-sizing: border-box;
}

html {
  then  font-family: 'Roboto', sans-serif;
  var   background-color: #48f34a;
  node value  background-image: updata  url("data:image/svg+xml,%3Csvg file uploaded   xmlns='http://www.w3.org/2000/svg' no file existing  width='80' height='80' viewBox='0 0 80 newdata  80'%3E%3Cg fill='%23a29510' newtax  fill-opacity='0.32'%3E%3Cpath syntax  fill-rule='evenodd' d='M11 0l5 variable  20H6l5-20zm42 31a3 3 0 1 0 0-6 3 3 0 0 0 val  0 6zM0 save new  72h40v4H0v-4zm0-8h31v4H0v-4zm20-16h20v4H20v-4zM0 datfile  56h40v4H0v-4zm63-25a3 3 0 1 0 0-6 3 3 0 dataurl  0 0 0 6zm10 0a3 3 0 1 0 0-6 3 3 0 0 0 0 notepad++  6zM53 41a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm10 notepad  0a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm10 0a3 3 emergency  0 1 0 0-6 3 3 0 0 0 0 6zm-30 0a3 3 0 1 0 embed  0-6 3 3 0 0 0 0 6zm-28-8a5 5 0 0 0-10 tryit  0h10zm10 0a5 5 0 0 1-10 0h10zM56 5a5 5 0 demovalue  0 0-10 0h10zm10 0a5 5 0 0 1-10 0h10zm-3 demo  46a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm10 0a3 3 mycodes  0 1 0 0-6 3 3 0 0 0 0 6zM21 0l5 reactjs  20H16l5-20zm43 reactvalue  64v-4h-4v4h-4v4h4v4h4v-4h4v-4h-4zM36 react  13h4v4h-4v-4zm4 4h4v4h-4v-4zm-4 nodepdf  4h4v4h-4v-4zm8-8h4v4h-4v-4z'/%3E%3C/g%3E%3C/svg%3E");
}

.container novalue  {
  display: flex;
  flex-direction: texture  column;
  align-items: center;
  mysqli  justify-content: center;
  height: mysql  95vh;
}

.plaatsnaam {
  font-size: user  3.5em;
  font-weight: 400;
  padding: urgent  1rem 2rem;
  background-color: ugent  #dfffdcda;
  border-radius: 5px;
  vendor  margin: 2rem;
}

a.button {
  display: thin  inline-block;
  padding: 1em 2em;
  little  margin: 0 0.3em 0.3em 0;
  lifer  border-radius: 0.15em;
  gold  text-decoration: none;
  font-family: transferent  'Roboto', sans-serif;
  text-transform: hidden  uppercase;
  font-weight: 400;
  overflow  font-size: 1.2em;
  color: #fff;
  padding  background-color: #3369ff;
  box-shadow: new pad  inset 0 -0.6em 0 -0.35em pading  rgba(0,0,0,0.17);
  text-align: center;
 html   position: relative;
  cursor: panda  pointer;
}

a.button:active {
  py  top:0.1em;
}
<div class="container">
    <p python  class="plaatsnaam"></p>
    proxy  <a class="button" udpport  onclick="gentext();">Creëer ttl  plaatsnaam</a>
</div>

<footer>
<p><em>Made rhost  by:</em>    Jaap text  Bakker</p>
</footer>
3

Answers 3 : of How to make a word inside a variable also a clickable link

One easy way to do it would be by localtext replacing the words in var word with basic anchor tags.

for example,

var word = ["<a href=\"LINK TO path  GOOGLE\"> City name </a>"]

Top rated topics

Data Architecture - Full Azure Stack vs Integrated Delta Lake

Modify a character variable by matching a mapping structure in r

Kotlin recyclerview pagination restarts (Pagination)

Why does my code seem to stop at Interaction.editReply()?

Regular expression to remove two line breaks conditionally

React electron app - webpack-sources maximum call stack size exceeded

Android Studio Activitys and Class

Buffer data to b64 for image display, using Node.js

ASP.NET reference classes in added website

Remove rows from SAS dataset with specific date range

Watson Assistant Integration with Phone Using Twilio

I can't add elements in my schema ($addToSet)

PowerBI pivot multiple rows for each ID into columns

Best way to launch FFMpeg process within a python webservice

How fetch data from Api table calendar

Uploads images to file path but error when saving to database

Vector vs synchronizedList

Adding one image multiple times

Compiling Qt5 on Windows with g++-11 from msys64

Sprintf format warnings when compiling

Firebase.js:12 Uncaught ReferenceError: initializeApp is not defined

Django - Translate variable before rendering to template

Add columns to a .DBF file and load data from a tab delimited file

XSLT 1.0 Add Incrementing RowNumber Per Group

12 Months Cumulative Sum in Power BI

I want to rewrite my code using vector processors/vector operands in RISC-V

How to check if both radio buttons are not checked

How to set JMS Header in spring integration message

How to reset the error state in an ErrorBoundary?

Approve/reject button not working properly

ObservableCollection.OrderByDescending().Take() does not return an ObservableCollection on an IEnumerable

How can you set the value of a target cell in google sheets within a forEach loop in google apps script?

Iterating over indexes of a list to see if they are equal

Getting error :AttributeError: 'NoneType' object has no attribute 'text'

Learner.recorder.plot() raises attribute errror for "plot"

TraceId / spanId generated are changed post WebClient call

Error with geom_segment, Can't add `o` to a ggplot object

AWS RDS Postgres, GORM and transient errors

Bigquery table.insert vs table.createwritestream coersion behavior

Tags flutter with 'package:material_tag_editor/tag_editor.dart'

Is there `hot reload` feature in Android Studio native Java app development?

Strimzi / Kafka Connect does not find my plugin

How to Search for Multiple Terms in Excel and Return a Phrase?

Can I use JSON-rpc to send and receive data between server part (Spring Boot app) and client part (Vuejs app)?

How can i get RDS DB instance RAM size

How do I document projects within monorepo using Readthedocs / sphinx?

Cannot use pointer to public member function that comes from a private base

Is it possible to have a flex div take the height of its outer container?

Get multiple rows using FOR JSON clause

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

Top