The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Click on a link (at a iframe) and send the code to txtarea (on topics)

2 posters

Go down

In progress Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Chavo April 1st 2014, 7:58 am

I've take this code and i've created a javascript page and applied to all pages. But the page which has the link (a emoticon) is in a frame (host on another site), so how i can place the code of this image when i click on it on textarea of topics (main frame "_top"). I've tested it on the site i've host and it worked fine, but the problem is make it works on main frame.
avatar
Chavo
New Member

Male Posts : 19
Reputation : 2
Language : Engish, Portuguese

https://help.forumotion.com/

Back to top Go down

In progress Re: Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Ange Tuteur April 1st 2014, 3:36 pm

Hello Chavo,

To access an iframes contents the source must be on the same domain.

Example :
Code:
$(function() {
    $('#emoticons').load(function() {
       $('#emoticons').contents().find('img').click(function() {
          $('#textArea').val($('#textArea').val() + $(this).attr('alt'));
       });
    });
});

http://generaltesting.forumotion.com/h1-
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Chavo April 1st 2014, 9:18 pm

And what codes i apply to iframe images? And it really must be hosted on forum?

On forumotion have an limit of maximum html modules?
avatar
Chavo
New Member

Male Posts : 19
Reputation : 2
Language : Engish, Portuguese

https://help.forumotion.com/

Back to top Go down

In progress Re: Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Ange Tuteur April 1st 2014, 10:14 pm

The code I posted above shows how to access the iframes html contents. For the emoticon codes, it is done by the alt text of the image. We target this attribute and insert its value into the texarea.

To access the contents of an iframe, the iframe source must be on the same domain.

The max number of HTML pages you can have is 500. Please see this topic for limits :
https://help.forumotion.com/t1709-some-limits-of-forumotion-forum
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Chavo April 3rd 2014, 4:03 am

So, i can put a texbox inside the frame and the person get it just pressing a button...

Have a possibility to switch automatically the theme when your internet is slow. 

And can apply a .css from the main frame to iframes on the page? And when switch the theme of the main frame switch on the iframe?
avatar
Chavo
New Member

Male Posts : 19
Reputation : 2
Language : Engish, Portuguese

https://help.forumotion.com/

Back to top Go down

In progress Re: Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Ange Tuteur April 3rd 2014, 4:16 am

If you wanted to append a stylesheet to the iframe you can do :
Code:
$(function() {
    $('#myFrame').load(function() {
       $('#myFrame').contents().find('head').append('<link type="text/css" href="/mystyle.css" rel="stylesheet">');
    });
});
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

In progress Re: Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Chavo April 4th 2014, 7:16 am

Two questions
This code will affect all pages on frame? If i go to another page it will be replaced by the theme of the page?

And how i modify this code for example make a list to choice the theme?
avatar
Chavo
New Member

Male Posts : 19
Reputation : 2
Language : Engish, Portuguese

https://help.forumotion.com/

Back to top Go down

In progress Re: Click on a link (at a iframe) and send the code to txtarea (on topics)

Post by Ange Tuteur April 4th 2014, 6:36 pm

To apply to all frame pages you would need to append the style again, so you could do something like :
Code:
var setStyle = setInterval(function() {
    if ($('#myIframe').contents().find('#myStyle').length) return;
    $('#myIframe').contents().find('head').append('<link type="text/css" id="myStyle" href="mystyle.css" rel="stylesheet">');
},100);

You could set up a list of elements and have them run a function if clicked. You would need to clear the other functions when doing so. So, on click of the new style you would run a similar function above and kill your other intervals by calling clearInterval.

ex :
Code:
$('#mybutton').click(function() { clearInterval(setStyle) });
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum