Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

74
Views
How to store HTML content within an array for Javascript?

My aim is to have a single web page which changes back and forth between two pieces of code every 60 seconds. I am able to do this with two urls/webpages using content refresh, however, ideally I am trying to include it all in one javascript file.

page1content and page2content indicate where I would want to insert the html code within the array. The HTML code is run within a js filter using Rhapsody Integration engine.

Any thoughts on how I might be able to get html content to switch between the two in a continous loop?

var next = output.append(input[0]);

var html = "";
html = html + "<style>";
html = html + "<span id=\"flicker\"></span>";
html = html + "</style>";

var pageContent = ["page1content", "page2content"];
var count = 0;

function changeContent() {
    $("#flicker").text(pageContent[count]);
    count < 2 ? count++ : count = 0;
}
setInterval(changeContent, 60000);

XMLData.setText(HTMLBody,'UTF8');
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try the snippet below:

const pageContent = [
` <p>This is from page 1.</p>
  <p>This is another paragraph from page 1.</p>`, 
` <p>This is from page 2.</p>
  <p>This is another paragraph from page 2.</p>`];
let count = 0;

function changeContent() {
    $("#flicker").html(pageContent[count]);
    count++; count %= 2;
}
setInterval(changeContent, 5000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="flicker"></div>

P.S: Setting the interval to 5 seconds to showcase the functionality more quickly

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!