Where are you using document.write
? Inside the text widget? If so, it should write text inside that widget, just like you want.
document.write
injects data where it’s encountered. So if you’re using it outside the document body it will produce unexpected results (like overwrite the document, in most cases).
**Update, add this in your text widget:
<div id="textwidget-content"> YOUR INITIAL TEXT HERE </div>
<script type="text/javascript">
var strings = new Array('Whatever', 'Bla blah', 'Boo', '....');
var t = setInterval(function(){
document.getElementById('textwidget-content').innerHTML = strings[Math.floor(Math.random()*(strings.length))];}, 1000);
</script>
Related Posts:
- Executing Javascript When a Widget is Added in the Backend
- Loading scripts only if a particular shortcode or widget is present
- How to refresh Theme Customizer after change color inside wpColorPicker?
- Elegantly using JavaScript on widget admin forms
- Add Descriptive text to Widget text box so users can see what they contain
- How to add a class to a link in text editor
- Run JS after widget settings are saved?
- AJAX Contact Form Issue
- Widget code is not working on WordPress.com Hosted Blogs
- Include chat (HTML, js, css) in all pages of WordPress
- How to determine the number of widgets contained in a sidebar via customizer JS
- jQuery UI inside widget on admin page
- Add description to custom text widget and display the 5 recent post titles
- WP_enqueue_script() loads them always in wp_footer()?
- How do I pass the id of my widget to javascript in the form function?
- Access Customizer widget instance form
- Unable to load “wpColorPicker” on theme customize page
- Render repeatable widget fields properly with Backbone.js
- Widget outputting JS as plain text
- Simple SCript Not Displayed in WIdth
- Loading scripts only if a particular shortcode or widget is present
- How to change text of a widget depend on condition?
- Widget Admin page and Javascript enqueuing
- List.js inside WordPress widget
- How can I use the built in WordPress “browse link” functionality?
- Code for Recent Posts Widget
- Modifying the default search widget
- Prevent widgets removal
- Is there a way to add more tags to the tag cloud?
- How to build widget with arrays inside arrays?
- How do I save data from submitted form from widget
- Why Can’t wp_editor Be Used in a Custom Widget?
- How to use control_callback when creating a widget via functions.php or plugin?
- Disable default WordPress widgets in sidebar
- Updating to Version 4.5 bumped my “main sidebar” widget out of place
- How can I delete all inactive widgets?
- Adding classes to dynamic sidebar
- Need help adding additional controls to a custom widget
- Why do none of my widgets have a title?
- Where are widget configurations stored?
- Adding a widget to a string of HTML
- WordPress widget new instance creates content duplicates
- Remove/Unregister or hide a widget added by a plugin
- Check if widget is active
- Radio buttons in widget not saving
- How to check if a widget has no title
- Including PHP files doesn’t work outside of Localhost
- Display sidebar only if it has content
- Excluding specific widgets from default sidebar class
- How to truncate titles in Recent Posts widget?
- Can WordPress Read Its Own RSS Feed?
- Can’t see widget areas in my customizer
- Debug errors on sidebar
- Dynamic sidebar based on category
- Widget textarea input gets formatted
- Show widget differently depending on if it’s in the sidebar or footer
- Get posts after today (upcoming events)
- How to pass data from page to widget functions?
- Adding a rich text editor to a widget – specifically CKEditor
- Is it possible to display tag cloud widget by category?
- Widget page is missing from menu and default widgets are not showing
- wp_editor in widget breaks after save (no buttons and visual tab broken)
- How to use a dropdown to populate a list of post from CPT
- Allow shortcode for custom widget
- Registering a stylesheet inside my WordPress widget
- is_tax() not working in Widget Logic [closed]
- How to position custom dashboard widgets on side column
- How do I remove/reset all current widgets from the database?
- what is the difference between these two types of widget form method
- Change Woocommerce Product Categories Widget ‘Title’ based on Product Category
- Why isn’t my custom widget outputting any content?
- Make single widget area top level in 4.0 Customize Panel
- Sidebar widgets – dynamic CSS : problem with widget-title
- widget not displayed
- Dynamically creating multiple widgets from Mustache templates
- changing the style of sidebar
- Vimeo Feed gived dead link with RSS widget?
- Preset Widgets ONLY after site is initially created
- Is it possible to add a preview to custom developed Widget?
- How to enable [archives] short code
- How to change widget title in wordpress version 5.8.1?
- script not working anymore after saving widget settings
- why the code html apear in this widget in footer
- A checkbox Option for description in Widget
- My widgets do not save
- How to move widget area to another section in WordPress Customizer
- Handling dozens of sidebars
- I cannot customize custom widgets anymore after moving WordPress website
- How can I only show a widget prior to a specific date?
- Add sidebar in inner pages
- Widget Areas Still Appearing in WP ADMIN When They Shouldn’t
- Dynamic Width of Widgets
- Inkness theme sidebar
- My Email Newsletter plugin will not configure when I try to import the widget
- Automatically hide Widgets that would lengthen page
- Imported blog page layout messed
- Widget on home page displays wrong time compared to same widget on inside pages
- Widget logic not working
- Sample widget code which get data(1-5 record) from Wp_Admin panel and display to Homepage(WordPress Custom Theme)
- Use custom Javascript for a custom Elementor Widget [closed]