Hey guys I want to change the source of some iframes if you load my page with an iphone. My Problem is that it works but just the first line the other two iframes dosn't get changed. Some ideas how to fix that?
if (navigator.userAgent.match(/iPhone/i)) {
document.getElementById("iframe-startpage-mobile").src = "placeholder_1/index.html";
document.getElementById("iframe-vrapp-mobile").src = "placeholder_2/index.html";
document.getElementById("iframe-360video-mobile").src = "placeholder_3/index.html";
}
I may figured out why it could not work: I insert this in wordpress fusionbuilder > avada > theme options > Space before so maybe wordpress don´t let it work normally
Try to add something like:
alert(document.getElementById("iframe-vrapp-mobile"))
Or do something equivalent in the console. To make the that element ID actually exists and it's an iframe.
i still don´t know why it doesn´t work, but i don´t need to fix it anymore.Now I dosn´t change my source of the iframe, i change my site when you load it on iphone. Thx for the attention. :)
Related
Hey guys I am trying to click on an element called practitioner access on my company's web site and I have tried looking up documentation on stack over flow and have not figured out how to do this exactly I need help. What I am trying to do is click on the practitioner access popup/drop down and I have not been able to find the code to do it. Please see epic at the bottom:
This is how far I have gotten so far but protractor cant find the element
var pracaccess = element(by.xpath("//contains(#onclick, 'Practitioner Access')"))
pracaccess.click();
browser.sleep(10000);
I have tried to use these site to try and help myself but I can't piece it together. Any help would be appreciated. I am new to xpath as well.
new info to possibly help:
Here is a more expanded view
Also this is what it looks like in vb-script but its basically the same any suggestions?
Browser("ADP_2").Page("ADP_3").Link("html tag:=A","innertext:=Practitioner Access").WaitProperty "visible",True,30000
Browser("ADP_2").Page("ADP_3").Link("html tag:=A","innertext:=Practitioner Access").Object.Click
This XPath expression would look for a tag with the contains tag name, which does not exist. Instead, you've actually meant:
//a[contains(#onclick, 'Practitioner Access')]
Or, there is a nicer way to locate an a element by the link text:
element(by.linkText("Practitioner Access"))
The answer by alecxe is correct but if you want it to be as xpath:
element(by.xpath('//a[text()="Practitioner Access"]'));
I have checked the answers, and this is my first project with jQuery:
function LoadWPage(a, b)
{
// this line works - the PART is the (spare)part I want to show when selected
document.getElementById("PART").innerHTML = "webshop.php?v="+a+"&p="+b;
// this is what I want to do, but nothing happens <------ my question
$("#PART").load("webshop.php?v="+a+"&p="+b);
// this is a dummy div and it loads well - I get the data from the PHP page
document.getElementById("sonnich").innerHTML = '<object type="text/html" data="webshop.php?v=+'+a+"&p="+b+'" ></object>';
// this simply leaves my div blank - why?
//document.getElementById("PART").innerHTML = '<object type="text/html" data="webshop.php?v=+'+a+"&p="+b+'" ></object>'; // leaves it empty
}
so, I can get the page I need to load, and even show it. It just does not work in jQuery. I googled it but did not find any clear answers to my problem.
The last line, which leaves it empty, I just dont get.
Any ideas?
WBR
Sonnich
The easiest way to test is to dump the entire jQuery library on top of your function. Copy & paste from https://code.jquery.com/jquery-2.1.4.min.js
This way, we know for sure jQuery is injected. Of course this is not a permanent solution, and just helps you narrow down your bug.
If it works, then you know your aren't injecting in jQuery. If it doesn't work, then something else is up.
*** if you are neat, you can use a function that inject in jQuery in your javascript
Injecting jQuery into a page fails when using Google AJAX Libraries API
Cheers,
I need help understanding what I'm doing wrong. I'm loading a page and grabbing two divs using .load works great no issues. but then I want to find one of those divs and remove the bootstrap class and possibly add another class .addClass() howeve rI can't even get the removeClass to work. Am I doing this correctly?
$(document).ready(function() {
$("#siteloader").load( "/men/Maria-Brown #qvImage, #qvContent" );
$("#qvImage").removeClass(" .col-xs-12");
});
Awww yes I figured it out. because the main.js loads the popup and has it set to hidden until the popup is triggered. the
$("#qvImage").removeClass("col-xs-12");
needed to be added to the function inside the main.js now it works great.
thanks guys
I am not a really good understanding guy in all aspects of jquery, but I think I have one suggestion that you should check:
$(document).ready(function(){
$("#siteloader").load( "/men/Maria-Brown #qvImage, #qvContent", function(){
$("#qvImage").removeClass(" .col-xs-12");
} );
});
so this means that you run the "removeClass()" function AFTER the load is done. Try it.. I think this should help.
I can't write the comments yet, so I'm writing it as an Answer...
I am trying to add iframe in my page. Its working fine in all the browser except IE8.
I have checkout stackoverflow.com. Many of the suggestion would be frameBorder="0". My scenario is i dont have a access to edit the line . so i tried using java script setAttribute but unfortunately its not working in IE8.
function removeBorder()
{
document.getElementById("myframe").frameBorder="0";
}
Is there any possibility to create dynamic Attribute ?
Could you please help me ? Thanks in advance.
this is the proper way to create an attribute in js
var att=document.createAttribute("frameBorder");
att.value = "0";
document.getElementById("myframe").setAttributeNode(att);
source : W3S
advice : read more about DOM elements and how to manipulate them
I have a small portion of code which works well on FF but I can't seem to get it to work on Safari unless I put an alert instruction anywhere inside of the whiles.
Anyone knows what may be the problem ?
var liste_ele = document.getElementsByClassName('accordion_content');
i=0;
while(i<liste_ele.length)
{
var j=0;
var liste_sel = liste_ele[i].getElementsByTagName('select');
while(j<liste_sel.length)
{
liste_sel[j].style.visibility = '';
j++;
}
i++;
}
Why don't you try setting visibility to visible instead of ''.
liste_sel[j].style.visibility = 'visible';
And are they really hidden by setting visibility to hidden or are the hidden by display:none that might also make a difference.
If putting an alert in your while loop solves the problem, it's almost certainly a timing issue. Where in the DOM is this code being run? Are you sure it's being run AFTER the elements you're trying to find are created?
A simple test would be to put your code inside a timeout:
window.setTimeout(function(){
// your code here
},100);
If that works, then your issue is related to order of operations; make sure your DOM is created before attempting to access it.
#jitter : I already tried to set visibility to visible, but I didn't have a result so I just tried '', hoping it would help. And yes, my elements are hidden and not undisplayed, otherwise my script wouldn't run perfect on FF.
#jvenema : This looks like a good solution indeed :)
Even though I don't know why would my elements not be created since they are initialised as visibility:hidden by another script in my firmware before I pass on them with this script :/
Anyway thanks, you just solved my problem (well I had solved it the good way, by modifying the script that sets it to hidden but I was curious :p) ! :)
If you don't need to block off the position then use the style display:none. Otherwise hide it initially as Safari will render the page initially with the style visibility:hidden you just won't be able to toggle it with Javascript. As a workaround just toggle the opacity with the javascript;
document.getElementById('Div').style.opacity = 0; to make it disappear
and
document.getElementById('Div').style.opacity = 100; to make it reappear.
Its holding up for me until Safari gets it together.