I know this is a question much discussed but I can’t figure out why it does not work for me.
This is my function:
function ShowComments(){ alert("fired"); var movieShareId = document.getElementById('movieId'); //alert("found div" + movieShareId.textContent || movieShareId.innerText); //alert("redirect location: /comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/"); window.location.href = "/comments.aspx?id=" + movieShareId.textContent || movieShareId.innerText + "/"; var newLocation = window.location; //alert("full location: " + window.location); }
If I have the alerts uncommented or if I have Mozilla’s bugzilla open it works fine, otherwise it does not redirect to the other page.
Any ideas why?
Related Posts:
- Wait 5 seconds before executing next line
- window.onload vs document.onload
- jQuery.click() vs onClick
- What is event bubbling and capturing?
- What is DOM Event delegation?
- Adding an onclick event to a div element
- iFrame onload JavaScript event
- How do you Hover in ReactJS? – onMouseLeave not registered during fast hover over
- How to remove all listeners in an element?
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- Is it possible to simulate key press events programmatically?
- window.onload vs $(document).ready()
- How to get scrollbar position with Javascript?
- Why onbeforeunload event is not firing
- How to make HTML element resizable using pure Javascript?
- What is TypeScript and why would I use it in place of JavaScript? [closed]
- How to do associative array/hashing in JavaScript
- map function for objects (instead of arrays)
- How to play audio?
- How to write a countdown timer in JavaScript?
- TypeScript foreach return [duplicate]
- “document.getElementByClass is not a function”
- What does “javascript:void(0)” mean?
- What does this symbol mean in JavaScript?
- Go back button in a page
- ‘react-scripts’ is not recognized as an internal or external command
- After $npm install, Getting Error: Cannot find module ‘../lib/utils/unsupported.js’
- What’s the best way to convert a number to a string in JavaScript?
- React Native: this.setState is not a function
- Angular ForEach in Angular4/Typescript?
- Timers in React Native (this.setTimeout)
- CSS height 100% percent not working
- Angular 4 setting selected option in Dropdown
- How can I upload files asynchronously with jQuery?
- Fire ontextchanged() event of an asp:TextBox via Javascript
- XMLHttpRequest module not defined/found
- Cannot read property ‘bind’ of undefined. React.js
- How can I convert an image into Base64 string using JavaScript?
- Javascript checkbox onChange
- Number prime test in JavaScript
- document.getElementById not working / Display
- What does ngf-select do and why is it needed for form validation?
- What is jQuery Unobtrusive Validation?
- CreateElement with id?
- Print PDF directly from JavaScript
- Set value of hidden input with jquery
- NPM install fails with node-gyp
- element.setAttribute is not a function
- gapi is not defined – Google sign in issue with gapi.auth2.init
- Remove all special characters with RegExp
- jQuery: Get selected element tag name
- Fully responsive HTML5 video
- Make Discord bot send picture with message with NodeJS
- RegEx for Javascript to allow only alphanumeric
- How to check for an undefined or null variable in JavaScript?
- HTML anchor link – href and onclick both?
- How to use forEach loop correctly in angular 2?
- javascript push multidimensional array
- How can I know which radio button is selected via jQuery?
- jquery toggleClass not working
- How to wrap the content of the main tinyMCE editor with extra tags
- How to handle malformed response from WP REST API?
- Javascript not working?
- Add Item to Custom TinyMCE Menu
- Modals using loops and ACF [closed]
- Changes to JS not reflected on site
- How do developers add “Smooth Transitions” to their sites?
- Exclude JS file from 404 error page
- Pass data from wordpress to javascript in JSON
- How can I get my Calculate Contact Form 7 field to update with jQuery? [closed]
- Contact Form 7 – Uncaught TypeError: wpcf7.initForm is not a function [closed]
- js addclass function not working as expected, intereaction or special WP somethign needed?
- Where is script-loader.php creating JS tags
- WP TinyMCE (Full + media ) – 4.8 JS Init Dynamicly
- Get a default value of the Customizer setting using wp.customize API (JS)
- Search for a keyword across post types in a Gutenberg component
- Calling a WordPress Custom JavaScript file
- print script on wordpress header after user registered
- How do I use this javascript correct with wordpress?
- Load external javascript files
- Javascript alert appears before tag
- Bootstrap bundle present in page source but not working
- Multiple jQuery inputs or binds in Customizer Control Javascripts
- How to display different content on the same page using different URLS
- Web cover page open when button clicked
- Replace script attr or link
- Remove escape characters from JSON string pulled from a database
- How to pass data to javascript in custom widget class
- Client side pre-save Javascript hook on all admin pages
- WP Gutenberg – custom block with two content fields
- How to identify which javascript is being executed
- How to keep close a sub-menu under homepage? [closed]
- How to implement custom URL handler to access JS modal content? [closed]
- Contact form 7 hide and show fields depending up on the condition [closed]
- Javascript 2 elements dependent onclick .toggle [closed]
- wp_enqueue has a resource but doesn’t generate a script tag [duplicate]
- Javascript not working on index.php but it is working on single post’s page
- Unable to change the location of a file
- How to load JavaScript modules with script_loader_tag hook?
- How to securely set dynamic HTML content with JavaScript?