This question already has answers here:
JavaScript: location.href to open in new window/tab?
(7 answers)
How to add/update an attribute to an HTML element using JavaScript?
(4 answers)
Closed 9 years ago.
So, this is my code:
function link1()
{
window.location.href="Example";
}
How do i achieve the _blank function in JS?
Cheers
(Note: I am not using a library, nor am i intending to atm)
window.open will do the trick.
function link1()
{
window.open("http://www.example.com");
}
Related
This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Why does jQuery or a DOM method such as getElementById not find the element?
(6 answers)
Closed 17 days ago.
I have this piece of code:
<script>
const timesFromCombobox = document.getElementById("cas");
timesFromCombobox.addEventListener('change', timesTracker);
function timesTracker(){
console.log("val: " + timesFromCombobox.value)
console.log(<?= getDataFromSheetByRow(timesFromCombobox.value, 'z_data'); ?> )
}
</script>
but when refreshing page I get this error: ReferenceError: timesFromCombobox is not defined. How to pass reference to the function?
This question already has answers here:
Accessing variables indirectly [duplicate]
(4 answers)
Closed 6 years ago.
<script type="text/javascript">
function parent_work_copy(track_number) {
document.form1.track_(track_number)_name.value=document.form1.track_(track_number)_parent_work.value;
}
</script>
If the link below is clicked, I want the line inside of the parent_work_copy function to be modified to:
document.form1.track_5_name.value=document.form1.track_5_parent_work.value
copy to track
How to do this?
Javascript object keys works as string
document.form1["track_"+track_number+"_name"].value=document.form1["track_"+track_number+"_parent_work"].value;
Do something like this :
document.form1['track_'+track_number+'_name'].value
This question already has answers here:
Checking if jquery is loaded using Javascript
(11 answers)
How to check what version of jQuery is loaded?
(13 answers)
Closed 6 years ago.
What is the best way to check wether jQuery script has been included to the page? I have one, but I don't think it's elegant.
try { $("body") } catch(e) { /* doesn't exist */ }
Like this:
if(window.jQuery)
{
//jquery found
}
This question already has answers here:
Sleep in JavaScript - delay between actions
(15 answers)
Closed 7 years ago.
On an JS event, I add a class moved to an element.
How can I remove this class after 1 second?
I use Meteor.
Use setTimeout func:
setTimeout(function(){$('YouElement').removeClass('ClassName');},1000);
This question already has answers here:
How can I detect changes in location hash?
(11 answers)
Closed 9 years ago.
How do I call a javascript function every time the URL has a change with the string after the hash?
for example
.com/onepage/
(onwindowload called)
.com/#1000
(need a function to be called)
.com/#500
(need a function to be called)
Here is a way......
window.location.watch(
'hash',
function(id,oldVal,newVal){
console.log(oldval+" to "+newVal);
//Do something.........
}
);