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
Related
I'm a little confused. I have to add a target="_blank" to my a. The problem is that tag a has an appeal to a script in angular. I don't know this js framework. I tried to find in documentation some kinda solutions but still doesn't work. Maybe any hints?
pug.js
li(
ng-click="visitElement"
ng-attr-target="_blank"
)
a visit element
angular.js
$scope.visitElement = (res) -> {
$location.url "/orgs"
}
So I was wondered what can I do more to add this atrr to my href.
You can use native HTML:
li
a(href='http://google.com', target='_blank') visit element
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. :)
I have a link with an inline attribute of style="color: #FF0000;". I recently upgraded to latest CKEditor, after years of neglect. Now when I call CKEDITOR.inline, it strips all the links.
I found http://docs.ckeditor.com/#!/api/CKEDITOR.dtd-property-S-editable, which doesn't have an a in there.
I did CKEDITOR.dtd.$editable.a = 1; and it still strips links. What am I missing here? I literally followed the flow from the API inline call to that, but it seems that I'm doing something wrong.
EDIT
I also find that is removing the class attribute from elements. Everything else seems okay.
Check out the guide about content filtering (ACF) in CKEditor. See also the working sample in CKEditor SDK which shows how ACF works in the default automatic mode and how to adjust it (which is what you need to do in your case).
try this:
CKEDITOR.config.allowedContent = true;
CKEDITOR.dtd.$removeEmpty['a'] = false;
CKEDITOR.config.extraAllowedContent = 'a[!href];' + '#';
CKEDITOR.config.protectedSource.push(/<a[^>]*><\/a>/g);
CKEDITOR.config.protectedSource.push(/<span*?[\s\S]*?\/span>/g);
I need to make my application run on all browsers and I have a div for which I set the css class in Javascript using the syntax
divNew.className = "highlightItem";
It works ok on IE, but when it comes to Firefox, Opera and Chrome it's not working at all. I have also tried other versions such as
var theDiv = document.getElementById(divNew);
theDiv.setAttribute("class", "highlightItem");
theDiv.setAttribute("className", "highlightItem");
with no success. Setting all the attributes through style isn't working either.
Are there any other ways of setting the css class for a div so that it works on the above mentioned browsers? Thanks a lot!
On this line:
var theDiv = document.getElementById(divNew);
You need the id of your div there as a string:
var theDiv = document.getElementById("my-div-ID");
Other than that it should work.
If you want to save yourself time with cross-browser issues look into jQuery - you would just do:
$("#my-div-ID").addClass("highlightItem");
I have some Javascript that finds all of the hyperlinks in a page that contain 'google' for example and changes the beginning of the url to another url.
I am trying to add a class to this affected link, however I am getting a lot of 'undefined' errors in the JS console. I have tried alert($(this).innerHTML)) which showed the contents of the hyperlink - clases and whatnot. But for some reason I cannot append a class. I have also tried using this.className += " socks". That also causes an undefined error. I think I am missing something simple!
Also is there a way of using a regex in the search, I am newish to Javascript.
Here is my code:
$("a[href*='google']").each(function(){
this.href = this.href.replace('http://www.google.co.uk','http://www.ask.com');
this.href = this.href.replace('http://www.google.com','http://www.ask.com');
$(this).addClass("socks");
});
Thanks very much for any help!
There is no error with this code that i can see:
http://jsfiddle.net/p7Sgj/
See this.
try
$("a[href*='google']").each(function(){
var href = $(this).attr('href');
href.replace('http://www.google.co.uk','http://www.ask.com');
href.replace('http://www.google.com','http://www.ask.com');
$(this).attr('href', href);
$(this).addClass("socks");
});
instead of using this.href. I guess your code doesn't reach the addClass part...
Also, use firebug (in case of firefox) or chrome developer tools (in case of chrome) for debugging. You can simply set a breakpoint, add watches, etc...
(In that case, make sure you use a so-called non-minified version of jQuery for easier debugging)
If your HTML code is
Hello
World
And your CSS is
.socks {
color:#f00;
}
Then your code should be working fine.
http://jsfiddle.net/k93TZ/2/
Working here.
It might be your html or css code.